欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JDBC鏈接MySQL8的注意事項(xiàng)及說明

 更新時(shí)間:2023年09月05日 09:28:58   作者:我是肖亮  
這篇文章主要介紹了JDBC鏈接MySQL8的注意事項(xiàng)及說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

JDBC鏈接MySQL8的注意事項(xiàng)

需要使用高版本的JDBC驅(qū)動(dòng),“mysql-connector-java 8”以上版本。

1. JDBC driver 由“com.mysql.jdbc.Driver”改為“com.mysql.cj.jdbc.Driver”。

2. JDBC url為:

jdbc:mysql://localhost/rs_report?userSSL=true&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT

3. 出現(xiàn)錯(cuò)誤:

“Establishing SSL connection withoutserver's identity verification is not recommended. According to MySQL 5.5.45+,5.6.26+ and 5.7.6+ requirements SSL connection must be established by defaultif explicit option isn't set. For compliance with existing applications notusing SSL the verifyServerCertificate property is set to 'false'. You needeither to explicitly disable SSL by setting useSSL=false, or set useSSL=trueand provide truststore for server certificate verification.”

解決方案,在url中加上“userSSL=true”或“userSSL=false”。

4. 出現(xiàn)錯(cuò)誤:

“java.sql.SQLException: The server time zonevalue '???ú±ê×??±??' is unrecognized or represents more than one time zone. Youmust configure either the server or JDBC driver (via the serverTimezoneconfiguration property) to use a more specifc time zone value if you want toutilize time zone support.”

解決方案,在url中加上“serverTimezone=GMT”。

jdbc如何連接MySQL8版本

驅(qū)動(dòng)包請(qǐng)到: https://mvnrepository.com/artifact/mysql/mysql-connector-java 下載適合自己的版本

注意事項(xiàng)

以下是jdbc配置,驅(qū)動(dòng)包不再是 com.mysql.jdbc.Driver 類了。

連接url需要制定時(shí)區(qū),時(shí)區(qū)可以到驅(qū)動(dòng)包的配置文件里找:lib/mysql-connector-java-8.0.11.jar!/com/mysql/cj/util/TimeZoneMapping.properties

driver=com.mysql.cj.jdbc.Driver
#url=jdbc:mysql://localhost:3306/javaee?useSSL=false&useUnicode=true&characterEncoding=utf8
url=jdbc:mysql://localhost:3306/javaee?useSSL=false&serverTimezone=Asia/Shanghai
username=root
password=root

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論