Ausnahme in Verbindung mit mysql über jdbc
Bekam ich die Ausnahme, wenn ich versucht habe zu verbinden mit mysql über jdbc.Diese Art von Frage schon gefragt, aber ich habe nicht die Lösung für mein problem, hier ist mein code...
public static void main(String[] args) {
String url="jdbc:mysql://localhost:3306/student?
autoReconnect=true&useSSL=false";
String user="root";
String pass="system";
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Now connecting to databse...\n");
Connection con=DriverManager.getConnection(url,user,pass);
System.out.println("Connected !!!\n");
con.close();
System.out.println("connection close !!!\n");
} catch (ClassNotFoundException | SQLException e) {System.out.println(e);
e.printStackTrace();
}
}
}
diese Ausnahme, die ich bekam...
run:
Now connecting to databse...
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
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.connectWithRetries(ConnectionImpl.java:2165)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2090)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
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:400)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at dbms_basic.Dbms_Basic.main(Dbms_Basic.java:28)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:3005)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1916)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1845)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1215)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2255)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2106)
... 13 more
BUILD SUCCESSFUL (total time: 4 seconds)
jemand mir helfen, diesen Fehler..
Lesen Sie den stacktrace sorgfältig und finden Sie einen NULLPOINTEREXCEPTION
so, wie man es loswerden... ich bin nur ein Anfänger..
"ist Ihr ConnectionImpl" Was redest du da? Code gehört nicht zu OP. Das ist in der MySQL-JDBC-Treiber-code, also eine third-party Bibliothek.
Warum sind Sie mit einem unveröffentlichten (Entwicklung/test) - version von MySQL? Versuchen Downgrade auf MySQL 5.7.19 (die neueste Version), oder sonst ein upgrade Ihrer Connector/J auf die Entwicklung version 8.0.7-dmr. Versucht, aktualisieren auf die jeweils neueste freigegebene Connector/J (5.1.44) könnte auch eine option sein.
vielen Dank , es funktioniert nach der Verwendung von MySql 5.7.19
so, wie man es loswerden... ich bin nur ein Anfänger..
"ist Ihr ConnectionImpl" Was redest du da? Code gehört nicht zu OP. Das ist in der MySQL-JDBC-Treiber-code, also eine third-party Bibliothek.
Warum sind Sie mit einem unveröffentlichten (Entwicklung/test) - version von MySQL? Versuchen Downgrade auf MySQL 5.7.19 (die neueste Version), oder sonst ein upgrade Ihrer Connector/J auf die Entwicklung version 8.0.7-dmr. Versucht, aktualisieren auf die jeweils neueste freigegebene Connector/J (5.1.44) könnte auch eine option sein.
vielen Dank , es funktioniert nach der Verwendung von MySql 5.7.19
InformationsquelleAutor kumar-kunal | 2017-09-10
Du musst angemeldet sein, um einen Kommentar abzugeben.
Verwenden neue Maven-Abhängigkeiten
mysql mysql-connector-java-8.0.11
InformationsquelleAutor user2114253
War ich mit einer aktuellen version von mysql-server mit einer älteren version von mysql-connector. Sobald ich Sie aktualisiert, um die neueste connector(8.0.11) dieses Problem geklärt für mich.
InformationsquelleAutor Keith Oakes
Ich würde versuchen, zu spielen, um die char-Kodierung setzt, zum Beispiel können Sie versuchen, verwenden Sie die folgende url
InformationsquelleAutor mger1979