获取此错误:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:917)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2330)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at database.DBConnection.getConnection(DBConnection.java:29)
at recordSystemMain.MainLoginController.isValidCredentials(MainLoginController.java:122)
at recordSystemMain.MainLoginController.loginButtonClick(MainLoginController.java:73)
... 58 more
我不明白为什么会这样!我在jdbc连接类中找不到任何错误
package database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/
public class DBConnection {
private Connection connection;
private String url = "jdbc:mysql://localhost:3305/uiustudentrecordsystem?verifyServerCertificate=false&useSSL=true";
private String user = "root";
private String pass = "1234";
public Connection getConnection() throws SQLException {
connection = DriverManager.getConnection(url,user,pass);
return connection;
}
}
我查了mysql,数据库肯定存在。如果数据库存在,那么为什么连接没有发生?
然而,这种联系仍然没有发生
暂无答案!
目前还没有任何答案,快来回答吧!