mysql的JDBC接口編程

mysql的JDBC接口驅動包的版本和mysql的版本間的關係可以在官網上查到,具體例子見下面,裏面沒有和JDBC版本匹配的相關描述。
http://dev.mysql.com/doc/relnotes/connector-j/en/news-5-1-34.html
Version 5.1.34 is a maintenance release of the production 5.1 branch. It is suitable for use with MySQL server versions 5.5, and 5.6.

大概有如下的對應關係,具體版本需要具體查一下
    Connector/J 5.1 支持Mysql 4.1、Mysql 5.0、Mysql 5.1、Mysql 6.0 alpha這些版本。
    Connector/J 5.0 支持MySQL 4.1、MySQL 5.0 servers、distributed transaction (XA)。
    Connector/J 3.1 支持MySQL 4.1、MySQL 5.0 servers、MySQL 5.0 except distributed transaction (XA) support。
    Connector/J 3.0 支持MySQL 3.x or MySQL 4.1。


下面是jdbc接口連接mysql的例子,連接串裏指定了字符編碼
try{
 Class.forName(com.mysql.jdbc.Driver);
 System.out.println(Success loading Mysql Driver!);
  String url ="jdbc:mysql://localhost/dbName?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
  Connection conn= DriverManager.getConnection(url);
}catch(Exception e)
{
 System.out.println(Error jdbc to mysql!);
 e.printStackTrace();

}



-----------------

轉載請著明出處:
blog.csdn.net/beiigang
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章