MySQL Connector to J 8.0 Q&A

Connection


Q:Driver/Datasource Class Name

A:
 低版本:com.mysql.jdbc.Driver
 高版本(5.7+):com.mysql.cj.jdbc.Driver
 

Q:Connection URL Syntax

A:
This is the generic format of the connection URL:

    protocol//[hosts][/database][?properties]

For example:

    jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=GMT%2B8

注:使用tomcat开设服务器(端口3306),数据库名test,属性使用‘&’分隔
 
 

Properties


Q:Using Character Sets and Unicode

A:
The character encoding between client and server is automatically detected upon connection. You must specify the encoding on server using the URL to connect database.
For example, to user UTF-8 chatacter sets with Connector/J. You can using "characterEncoding=utf8" to config your Connector/J.

MySQL Connector to J 8.0 Q&A
 

Q:Connecting Securely Using SSL

A:
SSL:Secure Socket Layer,用以保障在Internet上数据传输之安全,利用数据加密(Encryption)技术,可确保数据在网络上之传输过程中不会被截取及窃听。
For example:

    useSSL=true or useSSL=false

Q:使用JDBC驱动关于时区引发的问题

A:
1.降低MySQL版本(5.6以下)
2.增加serverTimezone=UTC或GMT,如果指定使用gmt+8时区,需要写为GMT%2B8,否则可能解析为空。

猜你喜欢

转载自blog.51cto.com/13801495/2127946
Q&A