tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pmirco@inwind.it" <pmi...@inwind.it>
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:

<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
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 (rs.next()) {
   int id = rs.getInt("id");
   String text = rs.getString("text");
   out.print("row#" + rs.getRow() + ": id=" + id + ", text=" + text);
   out.println("<br>");
}
stmt.close();
conn.close();
%>

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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message