MySQL Connector to J 8.0 Q&A
阿新 • • 發佈:2018-06-11
MySQL Connector/J JDBC 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.
?
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,否則可能解析為空。
MySQL Connector to J 8.0 Q&A