From: | Ola Sundell <ola(at)miranda(dot)org> |
---|---|
To: | Sulakshana Awsarikar <sulakshana(at)mithi(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Getting exact string length from char fields in JDBC |
Date: | 2002-01-23 13:28:46 |
Message-ID: | Pine.LNX.4.21.0201230826060.3011-100000@miranda.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)miranda(dot)org - olas(at)wiw(dot)org - ola(dot)sundell(at)personalchemistry(dot)com
http://miranda.org/~ola
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-01-25 02:08:19 | Re: Problem in ResultSet#getTimestamp() of 7.2b4 |
Previous Message | Sulakshana Awsarikar | 2002-01-23 13:02:58 | Getting exact string length from char fields in JDBC |