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

From Sulakshana Awsarikar
Subject Getting exact string length from char fields in JDBC
Date
Msg-id 008a01c1a40e$48244b00$0500a8c0@vsnl.net.in
Whole thread Raw
In response to Re: Handling null values in char fields from JDBC  ("Paulo Merson" <paulo@summa-tech.com>)
Responses Re: Getting exact string length from char fields in JDBC  (Ola Sundell <ola@miranda.org>)
List pgsql-jdbc
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


pgsql-jdbc by date:

Previous
From: "Sean Duffy"
Date:
Subject: Re: Handling null values in char fields from JDBC
Next
From: Ola Sundell
Date:
Subject: Re: Getting exact string length from char fields in JDBC