mysql的JDBC介面編程,mysqlJDBC介面編程

來源:互聯網
上載者:User

mysql的JDBC介面編程,mysqlJDBC介面編程
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

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.