1
mysql版本过新带来的问题:
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.
解决方案:在conURL也就是在建立连接时的url后加?serverTimezone=UTC
String connURL="jdbc:mysql://localhost:3306/userdb?serverTimezone=UTC";
Connection con=DriverManager.getConnection(connURL, "root", "********");
Connection con=DriverManager.getConnection(connURL, "root", "********");
2
打代码真的一定要认真不能有一点马虎当时打错了后面再想改回来真的是千难万难
数据库连接超时The driver has not received any packets from the server
可以检查一下class.forname
如果不是长时间没有操作数据库可能你遇到的只是代码错了而已,网上看了那么多解决方法结果只是代码错了导致连接不上,感觉报的异常有误导性啊!
出现的错误: