【发布时间】:2018-10-06 18:17:29
【问题描述】:
package dbb;
import java.sql.*;
public class test {
public static void main (String[] args) {
String url = "jdbc:mysql://localhost:3306/test";
String user = "root";
String pass = "1234";
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver Searched");
conn = DriverManager.getConnection(url, user, pass);
System.out.println("Connection Succeed" + conn);
} catch (ClassNotFoundException e) {
System.out.println("Driver Not Searched");
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
我在 java 上编写了这段代码,但有一些错误。 例如, .
显示已经搜索到Driver,但还是连接失败。
我该如何解决这个错误?
【问题讨论】:
-
将堆栈跟踪添加为文本而不是图像
-
你可以做错误日志提示的事情:使用
com.mysql.cj.jdbc.Driver;通过将useSSL=false添加到 url 来禁用 SSL。时区值看起来像是来自 SSL 握手的东西。