0
我在互聯網上有一個MySQL數據庫。我可以通過瀏覽器和MySQL Workbench成功訪問它。我將數據庫添加到Netbeans。當我試圖從數據庫連接Netbeans的我得到這個錯誤:我無法連接來自Netbeans的數據庫
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.
我也試圖通過使用RESTful Web服務連接數據庫。我得到這個錯誤:
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.
你可以提供你正在使用連接到數據庫的代碼。 –
Netbeans上的服務選項卡下有數據庫。我右鍵單擊數據庫,然後單擊新建連接。然後我輸入必要的信息。 – ekremk
執行查詢之前連接正在關閉。 –