Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection connection=DriverManager.getConnection("jdbc:odbc:mysql");用以上方式连接后中文乱码,用jdbc驱动连接则无问题,但是我想用jdbcodbc桥接,请问如何解决中文乱码?

解决方案 »

  1.   

    http://dev.mysql.com/doc/refman/5.1/zh/MySQL 5.1参考手册
      

  2.   

    http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/bridge.html
           // Load the JDBC-ODBC bridge driver
           Class.forName(sun.jdbc.odbc.JdbcOdbcDriver) ;
     
           // setup the properties 
           java.util.Properties prop = new java.util.Properties();
           prop.put("charSet", "Big5");
           prop.put("user", username);
           prop.put("password", password);
     
           // Connect to the database
           con = DriverManager.getConnection(url, prop);