2 messages in com.mysql.lists.javaRe: another encoding problem!
FromSent OnAttachments
pmi...@inwind.it03 Jan 2003 08:42 
Kaarle Kaila03 Jan 2003 11:31 
Subject:Re: another encoding problem!
From:Kaarle Kaila (kaar@iki.fi)
Date:01/03/2003 11:31:24 AM
List:com.mysql.lists.java

At 17:43 3.1.2003 +0100, pmi@inwind.it wrote:

I've this java code:

Why do you want to convert the text into ISO8859_1? That's hardly even a Unicode character set. The characters in your example are included in the default Latin1 characterset and you should not need the parameters at all.

The JDBC converts characters so that you can only access the table using JDBC if you use these conversions.

Check also my http://www.kk-software.fi/kalle/opensource.html page.

regards Kaarle

... Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/jdbctest?useUnicode=TRUE&characterEncoding=ISO8859_1", "usrjdbc", "pwd"); Statement stmt = conn.createStatement(); stmt.executeUpdate("INSERT INTO table (text) VALUES ('àèìùò')"); ResultSet rs = stmt.executeQuery("SELECT * FROM table"); while (rs.next()) { String text = rs.getString("text"); System.out.println("row#" + "text=" + text); } stmt.close(); conn.close(); ...

When print the content of the db with the getString method, I see my "italian" characters, but when I go to the MySQL prompt, I can see strange characters instead of the ones I tried to write. If I manualy try my "INSERT" statement from the MySQL prompt, then the characters are properly stored. I've tried to manually force the encoding of the string, using the getBytes() method, but nothing has changed.

MySQL uses the default ISO-8859-1 encoding, and since I'm telling to the JDBC driver to use ISO-8859-1, I can't explain what's wrong.

I just want to find a way to store these "italian" characters in the db as they are, not to convert them as "&#...;" or something like that.

I'm actually using MySQL3.23.36 and mysql-connector-j 2.0.14

To request this thread, e-mail <java@lists.mysql.com> To unsubscribe, e-mail <java-unsubscribe-kaarle.kaila=iki@lists.mysql.com>