RE: characterEncoding has no effect in connection url
"Gu Lei(Tech)" <[email protected]> Fri, 10 Aug 2007 17:26:48 +0800
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <52211CB529416546A229E346F4E0BF4A0265782A@Exchange-BE11.sohu-inc.com> |
I also tried useUnicode=true. It's the same. -----原始邮件----- 发件人: Gu Lei(Tech) [mailto:[email protected]] 发送时间: 2007年8月10日 17:10 收件人: [email protected] 主题: characterEncoding has no effect in connection url Under Redhat as4 x86_64 This is my java program: import java.sql.*; public class JdbcExample3 { public static void main(String args[]) { Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://10.11.17.85/test?useUnicode=false&characterEncoding=utf8", "test", ""); if(!conn.isClosed()) System.out.println("Successfully connected to " + "MySQL server using TCP/IP..."); Statement s = conn.createStatement (); s.executeQuery ("SELECT t FROM test"); ResultSet rs = s.getResultSet (); int count = 0; while (rs.next ()) { String tVal = rs.getString ("t"); System.out.println ( " t = " + tVal ); ++count; } rs.close (); s.close (); System.out.println (count + " rows were retrieved"); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); } finally { try { if(conn != null) conn.close(); } catch(SQLException e) {} } } } That program fetches some Chinese words from MySQL. When I changed characterEncoding=utf8 to characterEncoding=latin1 or any existed character set, the output won't change. It seems that characterEncoding= is no use in jdbc url. The output is dependent on environment variable LANG. When I change LANG, the output will also change. Driver is mysql-connector-java-5.0.7. MySQL Server's version is 5.0 and 5.1. Why characterEncoding in url has no effect? 非常感谢,祝您一切顺利 古雷 Network Operation Dept Tel:62728824 Mobile: 13501384181 Email: [email protected] msn: [email protected] gtalk:[email protected] -- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/[email protected]