From: | Zeljko Trogrlic <zeljko(at)technologist(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Cc: | "Peter Mount" <peter(at)retep(dot)org(dot)uk> |
Subject: | Re: JDBC and Unicode problem |
Date: | 2000-09-05 18:47:13 |
Message-ID: | 4.1.20000905201135.01494808@pop.tel.hr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
After browsing through hundreds of messages, downloading source etc. I
finally found how to use UNICODE from JDBC. This is problem because of bug
in driver which I'll explain later. I'll post that here to help other with
the same problem:
Check that PostgreSQL supports UNICODE with SELECT getdatabaseencoding();
Check that database is created for UNICODE: open psql and type \l[ENTER]
Maybe you should do just one of above; I'm not sure.
Check that you have correct code page during compiling Java source, or your
String constants will be wrong. In JBuilder 3.0: Project -> Properties ->
Compiler -> Encoding
And now solution for JDBC problems:
Add to Java parameters -Dfile.encoding=UTF-8
Everything should work now, but mind that all methods that use default
encoding (file readers/writers, string.toBytes()) will use UTF-8 so you
have to explicitly say which encoding you use.
This is because of bug in driver; in connection.ExecSQL there is line
buf = sql.getBytes();
This line uses platform default encoding. If you use Cp1250, sql statement
will be encoded for that code page, or whatever code page you use, BUT IT
SHOULD BE ENCODED FOR DATABASE'S CODE PAGE!
The best solution will be if Connection reads which encoding PostgreSQL
expects and to replace line with:
buf = sql.getBytes(javaEncodingName);
(PostgreSQL's UNICODE must be converted to standard UTF-8)
Less perfect, but also acceptable solution will be to inform driver somehow
which encoding to use.
One of the options will be to use "SET client_encoding", but PostgreSQL
don't have support for Unicode-to-something-else support.
Solution is based on Tatsuo Ishii's postings.
From | Date | Subject | |
---|---|---|---|
Next Message | Joachim Achtzehnter | 2000-09-06 05:47:16 | Re: JDBC Driver Help... |
Previous Message | Tom Samplonius | 2000-09-05 18:38:31 | ODBC (Windows) defaults to Read-Only? |