gpt4 book ai didi

java - 已发出连接错误信号的 PooledConnection 仍在使用中

转载 作者:搜寻专家 更新时间:2023-10-30 21:08:51 24 4
gpt4 key购买 nike

我发布查询 here我在运行 hibernate 查询后出现此错误,我不知道这是什么意思。所以几分钟后我重新运行查询,然后我没有错误,但我想知道我是如何得到它以及如何修复它的。

WARN  com.mchange.v2.c3p0.impl.NewPooledConnection - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
WARN com.mchange.v2.c3p0.impl.NewPooledConnection - [c3p0] Another error has occurred [ java.sql.SQLException: Invalid state, the Connection object is closed. ] which will not be reported to listeners!
java.sql.SQLException: Invalid state, the Connection object is closed.
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java:1713)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.clearWarnings(ConnectionJDBC2.java:2020)
at com.mchange.v2.c3p0.impl.NewProxyConnection.clearWarnings(NewProxyConnection.java:933)
at org.hibernate.util.JDBCExceptionReporter.handleAndClearWarnings(JDBCExceptionReporter.java:71)
at org.hibernate.util.JDBCExceptionReporter.logAndClearWarnings(JDBCExceptionReporter.java:49)
at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:472)
at org.hibernate.jdbc.ConnectionManager.aggressiveRelease(ConnectionManager.java:429)
at org.hibernate.jdbc.ConnectionManager.afterStatement(ConnectionManager.java:304)
at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:572)
at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:307)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
Caused by: java.sql.SQLException: I/O Error: Software caused connection abort: recv failed
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1053)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:465)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:778)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
... 8 more
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.DataInputStream.readFully(DataInputStream.java:195)
at java.io.DataInputStream.readFully(DataInputStream.java:169)
at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:842)
at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:723)
at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
at net.sourceforge.jtds.jdbc.ResponseStream.peek(ResponseStream.java:88)
at net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3932)
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1046)
... 16 more

更新:

我的第一个代码:

Session session = getSessionfactory().openSession();
session.beginTransaction();

ArrayList<Object[]> results = null;
try {
StringBuilder sb = new StringBuilder();
sb.append("select p from person p ");
sb.append("where CONTAINS(p.name , :myName) ");

Query q = session.createSQLQuery(sb.toString());
String myName = "Bob Jones";
q.setString("myName", "*" + myName + "*");

results = (ArrayList<Object[]>) q.list();

} catch (Exception e) {
logger.error("Error : ", e);
} finally {
session.close();
}

它不起作用,to fix it这是第二个版本:

Session session = getSessionfactory().openSession();
session.beginTransaction();

ArrayList<Object[]> results = null;
try {
StringBuilder sb = new StringBuilder();
sb.append("select p from person p ");
sb.append("where CONTAINS(p.name , :myName) ");

Query q = session.createSQLQuery(sb.toString());
String myName = "Bob Jones";
q.setString("myName", "\"*" + myName + "*\"");

results = (ArrayList<Object[]>) q.list();

} catch (Exception e) {
logger.error("Error : ", e);
} finally {
session.close();
}

尝试运行第二个版本,出现上述错误。

最佳答案

您的事务管理和/或连接管理代码可能已关闭。看起来你在出错后并没有释放到连接池的连接,并试图重用它。这可能是因为您使用了错误的异常处理习惯用法。

关于java - 已发出连接错误信号的 PooledConnection 仍在使用中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14121226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com