JDBC连接mysql错误总结
错误一:连接失败,发送请求时间0,接收请求时间0
错误如下:
错误连接数据库 [csyd] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database
Error connecting to database: (using class org.gjt.mm.mysql.Driver)
Communications link failure
The last packet successfully received from the server was 1 milliseconds ago. The last packet sent successfully to the server was 1 milliseconds ago.问题原因:
msyql开启了ssl认证,jdbc连接数据库时需要表明是否进行ssl连接。
解决办法:
方法一:
使用jdbc的url进行参数的添加,使用useSSL参数表明是否需要进行ssl连接。
示例:
String url = "jdbc:mysql://127.0.0.1:3306/ydmj?useSSL=false";方法二:
直接关闭mysql的ssl认证,物理上解决问题。
在linux下,修改配置文件my.cnf;在win下,修改配置文件my.ini。在配置文件下添加skip_ssl。
示例:
# disable_ssl
skip_ssl 

Comments | NOTHING