配置多个数据源
做了一个用Hibernate切换连接多个sqlserver数据库&其他数据库的程序,开始用ms的sqlserver驱动,用一段时间以后就会出现connection reset exception,后面改为jtds驱动+c3p0连接池,但还是不稳定,会报异常。不知道有什么好的方法能解决不稳定问题
问题补充 2011-09-04 17:54
异常信息如下:
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicRe
sourcePool.java:1805)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(Thre
adPoolAsynchronousRunner.java:547)
- com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@188e804 --
APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
- com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@188e804 --
APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@bb0a41
(com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@19e61f
d (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1334ec
d (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
Pending Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResou
rceTask@17a941e
com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResou
rceTask@9278cc
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5
,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(Unknown Source)
java.io.DataInputStream.readFully(Unknown Source)
java.io.DataInputStream.readFully(Unknown Source)
net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.j
ava:841)
net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket
.java:722)
net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStrea
m.java:466)
net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.jav
a:103)
net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2202)
net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:602)
net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2
.java:344)
net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3
.java:50)
net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:182)
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(Driver
ManagerDataSource.java:134)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledCon
nection(WrapperConnectionPoolDataSource.java:182)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledCon
nection(WrapperConnectionPoolDataSource.java:171)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnect
ionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicRes
ourcePool.java:1014)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicRe
sourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(Ba
sicResourcePool.java:1810)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run