zidong 发表于 2018-10-5 12:12:51

MySQL Connector to J 8.0 Q&A-chaooWoo的博客

Connection

Q:Driver/Datasource>  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//[?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,否则可能解析为空。


页: [1]
查看完整版本: MySQL Connector to J 8.0 Q&A-chaooWoo的博客