[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql-java
Subject: RE: Dynamically set character set
From: "Paul Wallace" <pwallace () twowaytv ! com ! au>
Date: 2005-09-14 0:12:57
Message-ID: 766DD168B8AFFB41B7FB1689163F15EA0294A4 () marge ! pyrmont ! twowaytv ! com ! au
[Download RAW message or body]
Hi & thanks,
I read the page you suggested, I tried:
String conString =
"jdbc:mysql://127.0.0.1/test1?user=root&password=root&characterEncoding=
tis620";
and
String conString =
"jdbc:mysql://127.0.0.1/test1?user=root&password=root&characterEncoding=
TIS620";
But my data still appears as ???. When setting the character set at DB
build time, it still works. I am out of ideas as to what I am doing
wrong to set the character set in the connection.
Thanks for any help
Paul.
Paul Wallace wrote:
> Hi I need to do the above, as I will not know what language/charset is
> being inserted in to my DB. How can I set the character set? I tried:
>
> Statement statement = connection.createStatement();
> statement.execute("SET CHARACTER SET tis620");
Paul,
That won't work with JDBC. You have to set the character set when you
connect, with the "characterEncoding=..." property. You can't change it
"on the fly", as the JDBC driver can't detect this, and will send data
in the wrong character encoding.
>
> ...insert my thai chars..;
>
> Is this legal? I am inserting and getting back the now infamous
> question marks. Setting the character set on DB build-time is fine,
> but I need to set it at insertion time. I have also tried appending
> charset on to the connection string - String conStr =
> "jdbc:mysql://127.0.0.1/test1?user=root&password=root&charset=tis620";
> - with no result. I found both these suggestions on 'net.
In reply to your earlier posting, did you use "characterEncoding=utf-8"
instead of "charset=..." (which has never been a configuration property
for the JDBC driver, btw)? That should make your application work w/
utf-8 data. Maybe the following section of the JDBC manual would help
here:
http://dev.mysql.com/doc/mysql/en/cj-character-sets.html
-Mark
- --
Mark Matthews
MySQL AB, Software Development Manager - Connectivity www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDJsY+tvXNTca6JD8RAsMZAJ9Om/mH7/WgcBZ9lGjxmFUtiztDIACggrrc
4OMgWuGiQgzirZqoG54bP34=
=o8rQ
-----END PGP SIGNATURE-----
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=mysql-java@progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic