tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
Subject jdbc, mysql and character encoding
Date Thu, 02 Jan 2003 11:54:39 GMT
I've my jsp, where I simply want to fill a table with some "italian" characters:

Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/jdbctest?useUnicode=true&characterEncoding=ISO-8859-1",
"usrjdbc", "pwd");
Statement stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO table (text) VALUES ('àèìùò')");
ResultSet rs = stmt.executeQuery("SELECT * FROM table");
while ( {
   int id = rs.getInt("id");
   String text = rs.getString("text");
   out.print("row#" + rs.getRow() + ": id=" + id + ", text=" + text);

Everything works fine, and when I print the content of the db with the getString mehotd, I
see my characters.
The problem is that when I go to the MySQL prompt, I can see strange characters isntead of
the ones I tried to write.

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

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message