JDBC鏈接MySQL8的注意事項(xiàng)及說明
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)文章
MySQL8.0內(nèi)存相關(guān)參數(shù)總結(jié)
這篇文章主要介紹了MySQL8.0內(nèi)存相關(guān)參數(shù)總結(jié),幫助大家更好的理解和學(xué)習(xí)mysql,感興趣的朋友可以了解下2020-08-08SQLyog錯(cuò)誤號(hào)碼MySQL?plugin?caching_sha2_password?could?not?
這篇文章主要介紹了SQLyog錯(cuò)誤號(hào)碼?plugin?caching_sha2_password?could?not?be?loaded的解決方法,需要的朋友可以參考下2023-06-06mysql 5.7以上版本安裝配置方法圖文教程(mysql 5.7.12\mysql 5.7.13\mysql 5.7.
這篇文章主要為大家分享了MySQL 5.7以上縮版本安裝配置方法圖文教程,包括mysql5.7.12、mysql5.7.13、mysql5.7.14安裝教程,包括感興趣的朋友可以參考一下2016-08-08K8s 如何部署 MySQL 8.0.20 主從復(fù)制結(jié)構(gòu)
這篇文章主要介紹了K8s 如何部署 MySQL 8.0.20 主從復(fù)制結(jié)構(gòu),本次使用 OpenEBS 來作為存儲(chǔ)引擎,OpenEBS 是一個(gè)開源的、可擴(kuò)展的存儲(chǔ)平臺(tái),它提供了一種簡單的方式來創(chuàng)建和管理持久化存儲(chǔ)卷,需要的朋友可以參考下2024-04-04適合新手的mysql日期類型轉(zhuǎn)換實(shí)例教程
Mysql作為一款開元的免費(fèi)關(guān)系型數(shù)據(jù)庫,用戶基礎(chǔ)非常龐大,下面這篇文章主要給大家介紹了關(guān)于mysql日期類型轉(zhuǎn)換的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-08-08