Joined: Thu May 01, 2008 11:42 pm Posts: 2 Location: Auckland, New Zealand
|
Hi
I've set up spring to do the transaction handling in the standard way:
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven/>
Then in my service classes I have:
@Transactional(readOnly = true)
All my methods are readonly transactions only reading from the database at this stage.
I then set up my datasource as so:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="idleConnectionTestPeriod" value="10800"/>
<property name="maxIdleTime" value="21600"/>
<property name="maxStatements" value="0"/>
</bean>
The url and username/password connect fine and the application runs for roughly two days with no problem. Then all of a sudden I get the following error:
[twl-play] WARN [Timer-0] ThreadPoolAsynchronousRunner.run(608) | com.mchange.v2.async.ThreadPoolAsynchronousRunner$ DeadlockDetector@1ab2f62 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
[twl-play] WARN [Timer-0] ThreadPoolAsynchronousRunner.run(624) | com.mchange.v2.async.ThreadPoolAsynchronousRunner$ DeadlockDetector@1ab2f62 -- APPARENT DEADLOCK!!! Complete Status:
And sql server kicks out my user I'm connecting with and application can no longer hit the database.
I've tried using DBCP and ran into countless problems. Where suddenly I can't connect to the database:
Caused by: java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(C onnectionJDBC2.java:385)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(C onnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.ja va:182)
at org.apache.commons.dbcp.DriverConnectionFactory.cr eateConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory. makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.pool.impl.GenericObjectPool.bor rowObject(GenericObjectPool.java:840)
at org.apache.commons.dbcp.PoolingDataSource.getConne ction(PoolingDataSource.java:96)
at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource.java:880)
at org.springframework.jdbc.datasource.DataSourceTran sactionManager.doBegin(DataSourceTransactionManage r.java:200)
... 39 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl .java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:519)
at sun.reflect.GeneratedMethodAccessor65.invoke(Unkno wn Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocke tForJDBC3(SharedSocket.java:304)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(Shar edSocket.java:255)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(C onnectionJDBC2.java:310)
I don't think I'm leaking connections as I thought spring closed up connections for you as long as your running in a transaction. My Dao's all extend HibernateDaoSupport.
I've used spring hibernate combination countless times with MySQL and oracle and never had these sorts of issues. Not sure if its the way my application is configured or something related to sqlserver database. I've read many related problems in various forums and was wondering if there is a recommended approach with sql server?
I'm using the following:
Hibernate - 3.2.5.ga
spring - 2.5.3
c3po - 0.9.1.2
|
|