hi, all
there is a timer in my program, and it does same database operations periodly. Everytime, it creates a new session, does some operations, then closes the session. The code likes this:
Session session = null;
try
{
session = sessionFactory.openSession();
...
session.save(obj);
session.flush();
session.connection().commit();
...
session.close();
}
catch(...)
When it is doing these operations, I cut off the connection with the database. The thread of the timer will be blocked without any exception thrown. So, the timer is "dead". Adding some log, I find the blocking takes place in save or commit. How can I deal with it?
I use SQL-SERVER2000 and dbcp connection pool. This is some configuration:
<session-factory>
<property name="show_sql">true</property>
<!-- properties for this SessionFactory only -->
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://...</property>
<property name="hibernate.connection.username">..</property>
<property name="hibernate.connection.password">..</property>
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.dbcp.maxActive">100</property>
<property name="hibernate.dbcp.whenExhaustedAction">1</property>
<property name="hibernate.dbcp.maxWait">120000</property>
<property name="hibernate.dbcp.maxIdle">10</property>
<property name="hibernate.dbcp.ps.maxActive">100</property>
<property name="hibernate.dbcp.ps.whenExhaustedAction">1</property>
<property name="hibernate.dbcp.ps.maxWait">120000</property>
<property name="hibernate.dbcp.ps.maxIdle">100</property>
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.Provider</property>
<!-- mapping files -->
<mapping resource="com/zte/zxpcs/glc/persist/Authentication.hbm.xml"/>
</session-factory>
|