Re: Getting exact string length from char fields in JDBC

Поиск
Список
Период
Сортировка
От Ola Sundell
Тема Re: Getting exact string length from char fields in JDBC
Дата
Msg-id Pine.LNX.4.21.0201230826060.3011-100000@miranda.org
обсуждение исходный текст
Ответ на Getting exact string length from char fields in JDBC  ("Sulakshana Awsarikar" <sulakshana@mithi.com>)
Список pgsql-jdbc
On Wed, 23 Jan 2002, Sulakshana Awsarikar wrote:

> Hi
>
> I have recently shifted from using MySQL to PostgreSQL. I have a field in my
> table which is of type char(10) .
>
> When I do a getString() for this field using JDBC, I get a string of 10
> characters even if the actual data  is say 5 characters in length. The
> remaining 5 characters are spaces.
>
> This was not happening while using MySQL.
>
> How can I get the actual data without spaces when I do a getString() without
> having to add any kind of trimming code in the Java code.
>
> regards
> Sulaksana

You can either change the datatype to VARCHAR, or add a TRIM() to the
column in the select statement.

Ola

--
Ola Sundell
ola@miranda.org - olas@wiw.org - ola.sundell@personalchemistry.com
http://miranda.org/~ola


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Sulakshana Awsarikar"
Дата:
Сообщение: Getting exact string length from char fields in JDBC
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Problem in ResultSet#getTimestamp() of 7.2b4