Re: Getting exact string length from char fields in JDBC - Mailing list pgsql-jdbc

From Ola Sundell
Subject Re: Getting exact string length from char fields in JDBC
Date
Msg-id Pine.LNX.4.21.0201230826060.3011-100000@miranda.org
Whole thread Raw
In response to Getting exact string length from char fields in JDBC  ("Sulakshana Awsarikar" <sulakshana@mithi.com>)
List 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 by date:

Previous
From: "Sulakshana Awsarikar"
Date:
Subject: Getting exact string length from char fields in JDBC
Next
From: Bruce Momjian
Date:
Subject: Re: Problem in ResultSet#getTimestamp() of 7.2b4