2

我正在使用带有 C3P0 的 Hibernate 4 作为其连接提供程序。我目前没有使用 Spring 框架。

开发环境

Windows 7
Eclipse Juno
JRE-7
JDK -7

我使用的罐子是...

hibernate-core-4.1.7.Final.jar
c3p0-0.9.2-pre6.jar
jtds-1.3.0.jar

但在同一个库路径中也有

hibernate-c3p0-4.1.1.Final.jar
spring-orm-3.2.0.RC1.jar

那些其他罐子(hibernate-c3p0-4.1.1.Final.jar 和 spring-orm-3.2.0.RC1.jar)是否有可能对这个错误产生一些影响(见下文)?

是的,整个弹簧框架罐子都在路上,但我只是想先习惯休眠。我真的不知道如何使用Spring。让我们暂时把这件事留在这里。

我可以创建连接并成功查询数据库。但我得到这个错误

就像是

Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@4d0106e5

WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@4d0106e5

我得到的错误非常重复。他们都是这样的

11월 30, 2012 4:39:59 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:39:59 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:39:59 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@4d0106e5
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@4d0106e5
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:17 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:17 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:17 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@40a4d015
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@40a4d015
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:17 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:17 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:17 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@2ee657fa
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@2ee657fa
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:18 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:18 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:18 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@51b2f91b
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@51b2f91b
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:19 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:19 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:19 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@7bb39e5e
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@7bb39e5e
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:21 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:21 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:21 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@155767ad
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@155767ad
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:22 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:22 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:22 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@299bdc58
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@299bdc58
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:22 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:22 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:22 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@550a9854
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@550a9854
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

11월 30, 2012 4:42:22 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] Exceptions occurred while trying to close a PooledConnection's resources normally.
11월 30, 2012 4:42:22 오후 com.mchange.v2.c3p0.impl.NewPooledConnection logCloseExceptions
INFO: [c3p0] NewPooledConnection close Exception.
java.sql.SQLException: I/O Error: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2388)
    at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:736)
    at net.sourceforge.jtds.jdbc.JtdsStatement.reset(JtdsStatement.java:722)
    at net.sourceforge.jtds.jdbc.JtdsStatement.close(JtdsStatement.java:966)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:718)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:592)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)
Caused by: java.io.IOException: Stream 2 attempting to read when no request has been sent
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:755)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2282)
    ... 9 more

11월 30, 2012 4:42:22 오후 com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask run
WARNING: Failed to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@67a80f8e
java.sql.SQLException: Some resources failed to close properly while closing com.mchange.v2.c3p0.impl.NewPooledConnection@67a80f8e
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:638)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:247)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:607)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1012)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:636)

提前致谢。让我知道是否有几点我可以改进写一个问题:)

编辑糟糕,我忘了粘贴我的配置。开始

<hibernate-configuration>

<session-factory>

 <!-- Database connection settings -->
 <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
 <!--  -->

 <!-- JDBC connection pool (use the built-in) -->
 <property name="connection.pool_size">5</property>

 <!-- connection pooling -->

        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <!-- 
        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>        
         -->
        <property name="hibernate.c3p0.acquire_increment" >1</property>
        <property name="hibernate.c3p0.idle_test_period">30</property>
        <property name="hibernate.c3p0.min_size">1</property>
        <property name="hibernate.c3p0.max_size">2</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.timeout">60</property>

        <!-- 
        <property name="hibernate.c3p0.acquireRetryAttempts">1</property>
        <property name="hibernate.c3p0.acquireRetryDelay">250</property>
         -->

 <!-- SQL dialect -->
 <!--  
 <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
 -->

 <!-- Enable Hibernate's automatic session context management -->
 <property name="current_session_context_class">thread</property>

 <!-- Disable the second-level cache -->
 <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

 <!-- Echo all executed SQL to stdout -->
 <property name="show_sql">true</property>

 <!-- Drop and re-create the database schema on startup -->
 <!-- <property name="hbm2ddl.auto">update</property> -->

 <!-- Mapping files -->
 <mapping resource="standard.hbm.xml"/>
 <mapping resource="revisionedFile.hbm.xml"/>
 <mapping resource="keyword.hbm.xml"/>  
 <mapping resource="device.hbm.xml"/>
 <mapping resource="reference.hbm.xml"/>
 <mapping resource="commonSpecification.hbm.xml"/>
 <mapping resource="item.hbm.xml"/>
 <mapping resource="superItem.hbm.xml"/>
 <mapping resource="defaultURLResource.hbm.xml" />
 <mapping resource="test.hbm.xml"/>

  <!--  Enver Listeners -->
   <listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
   <listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
   <listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>
   <listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-update"/>
   <listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-remove"/>
   <listener class="org.hibernate.envers.event.AuditEventListener" type="post-collection-recreate"/>


</session-factory>

</hibernate-configuration>  
4

1 回答 1

2

我不知道您为什么会看到异常,但它们是 c3p0 正在清理应该由用户关闭但没有关闭的语句的异常。解决问题的一种方法(既可以解决问题,也可以为您提供有关问题发生位置的更清晰信息)是确保您的客户端应用程序在使用语句后立即关闭语句。当您签入 Connections 时(或者在这种情况下,当从池中删除 PooledConnection 时)c3p0 会小心地为您清理未关闭的语句,但是如果发生异常,它们将在资源期间报告为异常-清理,即在 close() 期间。这就是你所看到的。

在 PooledConnection 被销毁时,您如何/为什么要关闭未缓存的 Statements,这有点神秘。池在签出时不应尝试 close() PooledConnection,如果已签入,则应在签入时清理语句。我将在记录器 com.mchange.v2.c3p0.impl.NewPooledConnection 中添加更多日志记录(在 FINER/DEBUG 级别),以帮助跟踪此问题的下一个 c3p0 预发行版。如果你有机会,请一定要看看。

于 2012-12-05T03:35:42.363 回答