常見問題一:
- Exception in thread “main” com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
- mysql-connector-java-5.1.37-bin.jar包和本地的MySQL Server 8.0版本不比對問題
-
建議下載下傳高版本的mysql-connector jar包
下載下傳步驟
https://dev.mysql.com/downloads/connector/j/
根據需求選擇IDEA連接配接MySQL踩過的坑 IDEA連接配接MySQL踩過的坑 IDEA連接配接MySQL踩過的坑
常見問題二:
- Loading class
com.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
- 注冊驅動檔案引入有誤
- 規範寫法:Class.forName(“com.mysql.cj.jdbc.Driver”);
- 可在jar包中檢視(版本6之後注冊驅動可以省略)
IDEA連接配接MySQL踩過的坑
常見問題三:
- Exception in thread “main” java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the ‘serverTimezone’ configuration property) to use a more specifc time zone value if you want to utilize time zone support.
- 6版本之後地jar包,url書寫不規範會引發時區問題
- 解決方案:規範書寫url