简体   繁体   中英

I can not connect database from Netbeans

I have a MySQL database on internet. I can reach it by browser and MySQL Workbench successfully. I added database to Netbeans. When I tried to connect database from Netbeans I get this error:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
Error code 0, SQL state 08S01: Communications link failure

The last packet successfully received from the server was 14.047 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.

I also tried to connect database by using restful web service. I get this error:

GET RequestFailed RequestFailed --> Status: (500) 
Response: {
HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Error Code: 0
Call: SELECT o_id, isim, not, yas FROM ogrenci
Query: ReadAllQuery(referenceClass=Ogrenci sql="SELECT o_id, isim, not, yas FROM ogrenci")
root cause

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
Error Code: 0
Call: SELECT o_id, isim, not, yas FROM ogrenci
Query: ReadAllQuery(referenceClass=Ogrenci sql="SELECT o_id, isim, not, yas FROM ogrenci")
root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
root cause

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 228.471 milliseconds ago.  The last packet sent successfully to the server was 11 milliseconds ago.
root cause

java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.

尝试增加mysql变量的wait_timeout

SET wait_timeout=300;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM