Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

RE: characterEncoding has no effect in connection url

From: Gu Lei(Tech) <leigu(at)sohu-inc.com>
Date: Fri Aug 10 2007 - 05:26:48 EDT


I also tried useUnicode=true. It's the same.

-----ԭʼÓʼþ-----
·¢¼þÈË: Gu Lei(Tech) [mailto:leigu@sohu-inc.com]
·¢ËÍʱ¼ä: 2007Äê8ÔÂ10ÈÕ 17:10

ÊÕ¼þÈË: java@lists.mysql.com
Ö÷Ìâ: 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) {}

    }
  }
}  
Do you need help?X

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?

·Ç³£¸Ðл£¬×£ÄúÒ»ÇÐ˳Àû

Do you need more help?X

¹ÅÀ×
Network Operation Dept
Tel:62728824
Mobile: 13501384181
Email: leigu@sohu-inc.com
msn: gl_yuanjue@hotmail.com
gtalk:gulei.om@gmail.com  

-- 
MySQL Java Mailing List
For list archives: 
http://lists.mysql.com/java
To unsubscribe:    
http://lists.mysql.com/java?unsub=lists@pantek.com
Received on Fri Aug 10 05:27:27 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:14:14 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library