jdbc连接数据库时 java.lang.RuntimeException错误怎么解决

Exception in thread "main" java.lang.RuntimeException: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.keji.util.JDBCUtil.getConnection(JDBCUtil.java:28)
    at com.keji.util.JDBCUtil.main(JDBCUtil.java:42)
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failurejdbc连接数据库时 java.lang.RuntimeException错误怎么解决_第1张图片

 解决办法

url中修改或加入这两个参数

useSSL=false&serverTimezone=Asia/Shanghai

 

你可能感兴趣的:(数据库,java,mysql)