Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A PooledConnection that has already signalled a Connection error is still in use

Tags:

java

hibernate

I post a query here I this error appears after running the hibernate query and I don't know what does it mean. So I rerun the query few minutes later, then I haven't the error but I wanna know how I get it and how to fix it.

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

Update :

My first code :

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();
}

It doesn't work, to fix it this is the 2nd version :

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();
}

Trying to run the 2nd version, I have the error above.

like image 881
user1940268 Avatar asked Jan 02 '13 11:01

user1940268


2 Answers

Your transaction-management and/or connection-management code is probably off. It seems that you are not releasing the connection to the connection pool after an error, and trying to reuse it. This may be due to a wrong exception-handling idiom you are using.

like image 156
Marko Topolnik Avatar answered Oct 17 '22 06:10

Marko Topolnik


By using jTDS you are probably trying to connect to MS SQL or Sybase. Based on the code you posted everything looks fine. I suggests you look to upgrading your driver and raising your logging level for more detail logs.

like image 27
MegaChan Avatar answered Oct 17 '22 08:10

MegaChan