From: | joe user <palehaole(at)yahoo(dot)com> |
---|---|
To: | Kris Jurka <books(at)ejurka(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: A JDBC bug or problem relating to string length in Java |
Date: | 2003-09-03 21:18:12 |
Message-ID: | 20030903211812.44426.qmail@web20405.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Zak McGregor | 2003-09-04 02:53:01 | Threadsafe from which version? |
Previous Message | Nicolas Modrzyk | 2003-09-03 17:08:13 | Postgresql java and blobs |