Home > Back-end >  Java project connect to the database error create connection SQLException
Java project connect to the database error create connection SQLException

Time:01-30

The 2018-05-02 22:13:47. 19 | create connection SQLException,
Url: JDBC: mysql://XXXXXXXXX? ServerTimezone=Hongkong& UseUnicode=true& CharacterEncoding=utf8 & amp; UseSSL=false& AutoReconnect=true& UseServerPrepStmts=true, errorCode 0, 08001
the state
Java. SQL. SQLNonTransientConnectionException: Could not create connection to the database server Attempted reconnect 3 times. Giving up.
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 108)
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 95)
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 87)
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 61)
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 71)
At com. Mysql. Cj. JDBC. ConnectionImpl. ConnectWithRetries (ConnectionImpl. Java: 932)
At com. Mysql. Cj. JDBC. ConnectionImpl. CreateNewIO (ConnectionImpl. Java: 857)
At com. Mysql. Cj. JDBC. ConnectionImpl. & lt; Init> (ConnectionImpl. Java: 444)
At com. Mysql. Cj. JDBC. ConnectionImpl. GetInstance (ConnectionImpl. Java: 230)
At com. Mysql. Cj. JDBC. NonRegisteringDriver. Connect (NonRegisteringDriver. Java: 226)
At com. Alibaba. Druid. Filter. FilterChainImpl. Connection_connect (FilterChainImpl. Java: 149)
At com. Alibaba. Druid. Filter. Stat. StatFilter. Connection_connect (StatFilter. Java: 218)
At com. Alibaba. Druid. Filter. FilterChainImpl. Connection_connect (FilterChainImpl. Java: 143)
At com. Alibaba. Druid. Pool. DruidAbstractDataSource. CreatePhysicalConnection (DruidAbstractDataSource. Java: 1515)
At com. Alibaba. Druid. Pool. DruidAbstractDataSource. CreatePhysicalConnection (DruidAbstractDataSource. Java: 1578)
At com. Alibaba. Druid. Pool. DruidDataSource $CreateConnectionThread. Run (2466) DruidDataSource. Java:
Under Caused by: com. Mysql. Cj. Exceptions. CJCommunicationsException: Communications link failure

The last packet sent successfully to The server was 0 milliseconds line. The driver has not received any packets from The server.
At sun. Reflect. NativeConstructorAccessorImpl. NewInstance0 (Native Method)
At sun. Reflect. NativeConstructorAccessorImpl. NewInstance (Unknown Source)
At sun. Reflect. DelegatingConstructorAccessorImpl. NewInstance (Unknown Source)
The at Java. Lang. Reflect. Constructor. NewInstance (Unknown Source)
At com. Mysql. Cj. Exceptions. ExceptionFactory. CreateException (ExceptionFactory. Java: 59)
At com. Mysql. Cj. Exceptions. ExceptionFactory. CreateException (ExceptionFactory. Java: 103)
At com. Mysql. Cj. Exceptions. ExceptionFactory. CreateException (ExceptionFactory. Java: 149)
At com. Mysql. Cj. Exceptions. ExceptionFactory. CreateCommunicationsException (ExceptionFactory. Java: 165)
At com. Mysql. Cj. Protocol. A.N ativeSocketConnection. Connect (NativeSocketConnection. Java: 92)
At com. Mysql. Cj. NativeSession. Connect (NativeSession. Java: 152)
At com. Mysql. Cj. JDBC. ConnectionImpl. ConnectWithRetries (ConnectionImpl. Java: 876)
. 10 more
Under Caused by: java.net.SocketException: No buffer space available (maximum connections reached?) : connect
The at java.net.DualStackPlainSocketImpl.connect0 (Native Method)
The at java.net.DualStackPlainSocketImpl.socketConnect (Unknown Source)
The at java.net.AbstractPlainSocketImpl.doConnect (Unknown Source)
The at java.net.AbstractPlainSocketImpl.connectToAddress (Unknown Source)
The at java.net.AbstractPlainSocketImpl.connect (Unknown Source)
The at java.net.PlainSocketImpl.connect (Unknown Source)
The at java.net.SocksSocketImpl.connect (Unknown Source)
The at java.net.Socket.connect (Unknown Source)
At com. Mysql. Cj. Protocol. StandardSocketFactory. Connect (StandardSocketFactory. Java: 173)
At com. Mysql. Cj. Protocol. A.N ativeSocketConnection. Connect (NativeSocketConnection. Java: 66)
. 12 more

Help everybody to see, the project on the server, start the tomcat rev up after, thank you!

CodePudding user response:

Check your connection address, login account and password, and account access

CodePudding user response:

There are several may lead to

1, mysql is the assigned account to allow remote connection
2, the port is correct, the default port 3306
3, the firewall

Can use Telnet test under the first database port service is normal

CodePudding user response:

Try using a local database client connection, look to whether can log in, by the way, two right upstairs

CodePudding user response:

[[[problems added]]]]
The database connection: driverClassName=com. Mysql. Cj). The JDBC Driver
Mysql version: 5.7
The JDK: 1.8
Problem description: a while will be submitted to the following anomaly, but system can use; Tomcat has stopped publishing system after starting

CodePudding user response:

[[[problems added 2]]]]
After restart the server, start tomcat, the project can use normally again

CodePudding user response:

Local login completely normal, no problem, it is run on the server after a period of time, there will be such a question, consider, probably has something to do with the server's configuration

CodePudding user response:

Abnormal, check mysql connections, if you don't release to connect,

CodePudding user response:

Connection with alibaba's connection poolnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related