I'm having problems reading unicode strings from MySql with Java. If I use
Sun's odbc/jdbc bridge the data is read correctly, but it's extremely slow.
If I use Connector/J it's just the opposite. The data is read correctly but
I can only display it correctly with println. Swing components display
garbage. My database is setup for unicode with the default character set =
sjis. If I try to use useUnicode=true&characterEncoding=sjis (or pretty much
any other encoding) the connection fails. Any suggestions?
thank you,
Chris
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/doc/ (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <java-th...@lists.mysql.com>
To unsubscribe, e-mail <java-unsubscribe-mysql-java=freebsd.csie...@lists.mysql.com>
Chris wrote:
> Hello everyone.
>
> I'm having problems reading unicode strings from MySql with Java. If I use
> Sun's odbc/jdbc bridge the data is read correctly, but it's extremely slow.
> If I use Connector/J it's just the opposite. The data is read correctly but
> I can only display it correctly with println. Swing components display
> garbage. My database is setup for unicode with the default character set =
> sjis. If I try to use useUnicode=true&characterEncoding=sjis (or pretty much
> any other encoding) the connection fails. Any suggestions?
>
> thank you,
> Chris
You don't say what version of the driver you are using, or how your
swing components extract data from the JDBC api. We'll need that
information to be able to help you.
-Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE961l9tvXNTca6JD8RAm/wAJ9Sj4DApC+JQ/ekrIqDe0Mx2vUHfQCbBRda
zUwKXJtoybMMkWpEJHrgK1U=
=XviO
-----END PGP SIGNATURE-----
Chris
Chris wrote:
> I'm using MySql 3.23.49, MyOdbc 3.51 and Connector/J 2.0.14. I'm using jdbc,
> getString() to extract the data to a java string. The column is defined as a
> varchar. The Swing components are JText fields and columns in a JTable. I
> can get user input correctly and apparently write the data correctly, at
> least running mysql from a command line prompt and issueing a select shows
> the data to look correct. It doesn't seem to matter which driver I use to
> write the data, Sun's bridge (Microsoft's too, although their JVM introduces
> other issues) read the data so that it is displayed correctly.
>
> Chris
Did you add 'useUnicode=true&characterEncoding=***' where *** is the
character encoding you want to use to your JDBC url? There's more
information about this in the README that comes with the driver.
-Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9619htvXNTca6JD8RAg/hAJ43pT3i6ojpzqXhqjhnxt79xVsvygCgqwDP
nPEGzDFyWGfaSuJHmU9G59Y=
=ztlT
Chris
----- Original Message -----
From: "Mark Matthews" <mmat...@thematthews.org>
To: "Chris" <ch...@env-soft.com>
Cc: <ja...@lists.mysql.com>
Sent: Monday, December 02, 2002 8:25 AM
Subject: Re: mysql and unicode
Chris wrote:
> Yes. I've checked the Connector/J code too. If I specify the encoding on the
> url it fails when the code attempts to getbytes using the encoding. If I
> don't specify the encoding the driver pulls 'sjis' from MySql's setup and
> attempts to use that. Again, getbytes fails. I tried using other encodings
> too with the same results. Since the encodings fail, I either get a
> connection error (when specified in the url) and the code exits or the
> encoding fails (reading from mysql itself) and useUnicode becomes false and
> the driver does not correctly translate the bytes read into unicode char's.
>
> Chris
What are you putting in for your encoding in the URL, 'sjis' or 'SJIS'?
You need to use the Java encoding name which is 'SJIS', and your JVM
also needs to support that encoding. Did you download the full JRE or
the JDK? Some of the downloads that Sun has don't support all Unicode
encodings.
-Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE962ektvXNTca6JD8RAu2aAJ91k/fQ7YsuYnFUlpXVf1coQGv8awCggXZ1
nJweB0VJfVyBa64kDKoIFDE=
=OPYv
Thank you
Chris
----- Original Message -----
From: "Mark Matthews" <mmat...@thematthews.org>
To: "Chris" <ch...@env-soft.com>
Cc: <ja...@lists.mysql.com>
Sent: Monday, December 02, 2002 9:01 AM
Subject: Re: mysql and unicode
hi,
I wrote a simple example in a JUnit testcase for using Unicode with MySQL.
You can find it on my OpenSource page. You'll find a link to there
on http://www.kk-software.fi.
regards
Kaarle
>I'm having problems reading unicode strings from MySql with Java. If I use
>Sun's odbc/jdbc bridge the data is read correctly, but it's extremely slow.
>If I use Connector/J it's just the opposite. The data is read correctly but
>I can only display it correctly with println. Swing components display
>garbage. My database is setup for unicode with the default character set =
>sjis. If I try to use useUnicode=true&characterEncoding=sjis (or pretty much
>any other encoding) the connection fails. Any suggestions?
>
>thank you,
>Chris
>
>
>---------------------------------------------------------------------
>Before posting, please check:
> http://www.mysql.com/doc/ (the manual)
> http://lists.mysql.com/ (the list archive)
>
>To request this thread, e-mail <java-th...@lists.mysql.com>
>To unsubscribe, e-mail <java-unsubscribe-kaarle.kaila=iki...@lists.mysql.com>
---------------------------------------------
Kaarle Kaila
http://www.iki.fi/kaila
mailto:kaarle...@iki.fi
tel: +358 50 3725844