这是错误:
5760 feb 04 07:45:17 TestServer java[13777]: java.sql.SQLNonTransientConnectionException: Could not read resultset: unexpected end of stream, read 0bytes from 4
5761 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:136)
5762 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.SQLExceptionMapper.throwException(SQLExceptionMapper.java:106)
5763 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.MySQLStatement.executeQueryEpilog(MySQLStatement.java:264)
5764 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:288)
5765 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.MySQLStatement.executeUpdate(MySQLStatement.java:317)
5766 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.MySQLPreparedStatement.executeUpdate(MySQLPreparedStatement.java:156)
5767 feb 04 07:45:17 TestServer java[13777]: at com.zaxxer.hikari.proxy.PreparedStatementProxy.executeUpdate(PreparedStatementProxy.java:61)
5768 feb 04 07:45:17 TestServer java[13777]: at com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy.executeUpdate(PreparedStatementJavassistProxy.java)
5769 feb 04 07:45:17 TestServer java[13777]: at com.testserver.deviceapi.data.DataDAO.insertBootEvent(DataDAO.java:64)
5770 feb 04 07:45:17 TestServer java[13777]: at com.testserver.deviceapi.server.ServerRunnable.processJsonObject(ServerRunnable.java:198)
5771 feb 04 07:45:17 TestServer java[13777]: at com.testserver.deviceapi.server.ServerRunnable.run(ServerRunnable.java:93)
5772 feb 04 07:45:17 TestServer java[13777]: at java.lang.Thread.run(Thread.java:745)
5773 feb 04 07:45:17 TestServer java[13777]: Caused by: org.mariadb.jdbc.internal.common.QueryException: Could not read resultset: unexpected end of stream, read 0bytes from 4
5774 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.mysql.MySQLProtocol.getResult(MySQLProtocol.java:926)
5775 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:991)
5776 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:281)
5777 feb 04 07:45:17 TestServer java[13777]: ... 8 more
5778 feb 04 07:45:17 TestServer java[13777]: Caused by: java.io.EOFException: unexpected end of stream, read 0bytes from 4
5779 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.common.packet.buffer.ReadUtil.readFully(ReadUtil.java:84)
5780 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.common.packet.buffer.ReadUtil.readFully(ReadUtil.java:92)
5781 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.common.packet.RawPacket.nextPacket(RawPacket.java:77)
5782 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.common.packet.SyncPacketFetcher.getRawPacket(SyncPacketFetcher.java:67)
5783 feb 04 07:45:17 TestServer java[13777]: at org.mariadb.jdbc.internal.mysql.MySQLProtocol.getResult(MySQLProtocol.java:894)
5784 feb 04 07:45:17 TestServer java[13777]: ... 10 more
该服务器是一个 java 服务器,在 CentOS 上作为服务运行。我昨天才将它实现为服务,这是我第一次尝试做类似的事情。截至昨天晚上,一切正常。我已经从 LAN 测试了服务器并从 LAN 外部连接没有任何问题,所有数据都已成功处理和保存。
以下是Javadoc必须说的SQLNonTransientConnectionException
:
为 SQLState 类值“08”或在供应商指定的条件下引发的 SQLException 的子类。这表示如果在未更正失败原因的情况下重试操作,则失败的连接操作将不会成功。请查阅您的驱动程序供应商文档以了解可能引发此异常的供应商指定的条件。
SQL 类值“08”表示:
Table 6. Class Code 08: Connection Exception SQLSTATE Value Meaning 08001 The connection was unable to be established to the application server or other server. 08002 The connection already exists. 08003 The connection does not exist. 08004 The application server rejected establishment of the connection.
所以我今天早上进来并尝试在发生这些错误时使用我的测试客户端将一些数据保存到数据库中。经过几次尝试后,我在本地计算机上运行了完全相同的版本的服务器,并且它没有任何问题地运行,成功连接到主服务器上的数据库并从同一个客户端保存了相同的数据,没有任何问题。
接下来我重新启动了主服务器上的服务。从那时起,一切都恢复正常,我对导致错误的原因一无所知。
会是这样吗?但是那个错误信息是Last packet not finished
我的Could not read resultset: unexpected end of stream, read 0bytes from 4
。
你们知道这可能是什么吗?我应该如何处理?由于错误清楚地表明问题不会在重试时自行解决,我想我可以捕获错误并关闭服务器。该服务设置为立即重新启动,因此 CentOS 将在它自行关闭后重新启动它。这是合理的做法吗?