Re: A JDBC bug or problem relating to string length in Java - Mailing list pgsql-jdbc

From joe user
Subject Re: A JDBC bug or problem relating to string length in Java
Date
Msg-id 20030903211812.44426.qmail@web20405.mail.yahoo.com
Whole thread Raw
In response to Re: A JDBC bug or problem relating to string length in Java  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
> SELECT datname,pg_encoding_to_char(encoding) FROM
> pg_database;

Thanks for the suggestion Kris.  I also got some help
from Barry.  The problem is that the encoding in the
db was ascii, which causes a discrepency between Java
string lengths and the string lengths in the db.  The
solution is to drop and recreate the db using unicode
encoding.

One conclusion from this is that, as a Java developer,
unless you are absolutely sure that all the strings
you are dealing with really are ascii, you should be
sure that the db has unicode encoding.  Java does not
internally use ascii for anything.  Everything in Java
is UTF-16, so external storage that Java uses should
be able to represent the full range of UTF characters.
 I think this would make a good entry in the JDBC FAQ:
"Always use Unicode encoding when using the JDBC
unless you are sure that you are only dealing with
ASCII."

Thanks


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

pgsql-jdbc by date:

Previous
From: Nicolas Modrzyk
Date:
Subject: Postgresql java and blobs
Next
From: Zak McGregor
Date:
Subject: Threadsafe from which version?