ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <erlend.bjo...@aftenposten.no>
Subject SV: Connection leak
Date Tue, 07 Jun 2005 07:20:37 GMT
Hi there!

>Is there a way to limit the maximum number of connections (at any given 
>time) Apache's DBCP pool?   

We haven't used that one, but have you tried the simple datasource ?
Is it the same behaviour ?

Our config look like this:

        <dataSource type="SIMPLE">
            <property name="JDBC.Driver" value="${driver}"/>
            <property name="JDBC.ConnectionURL" value="${url}"/>
            <property name="JDBC.Username" value="${username}"/>
            <property name="JDBC.Password" value="${password}"/>
            <property name="Pool.MaximumActiveConnections" value="30"/>
            <property name="Pool.MaximumIdleConnections" value="0"/>
            <property name="Pool.MaximumCheckoutTime" value="60000"/>
            <property name="Pool.TimeToWait" value="7000"/>
            <property name="Pool.PingQuery" value="select 1 as ISPINGWORKING from dual"/>
            <property name="Pool.PingEnabled" value="true"/>
            <property name="Pool.PingConnectionsOlderThan" value="1000"/>
            <property name="Pool.PingConnectionsNotUsedFor" value="1000"/>

We use Oracle too, 9.2 ... With the classes12.jar driver.

With the ping stuff .... You will also get something like this when you are in debug mode
for log4j:

DEBUG 09:02:43,041 [main] com.ibatis.common.jdbc.SimpleDataSource - Testing connection 25942001...
DEBUG 09:02:43,051 [main] com.ibatis.common.jdbc.SimpleDataSource - Connection 25942001 is
GOOD!
DEBUG 09:02:43,061 [main] com.ibatis.common.jdbc.SimpleDataSource - Closed connection 25942001.

When you have explisit transaction handling:

            sqlMap.startTransaction();
            sqlMap.commitTransaction();
		sqlMap.endTransaction();

So when you get closed connection, it's all cleaned up. 

---

When you have implisit transaction handling... The connection get closed automatically. 
Don't you see that in debug mode with log4j ??

--

I also recommend you to e.g use a dynamic proxy ... Then you can call sqlMap.endTransaction()
in a finally
clause in the invoke() method and you make sure the connection is returned independently if
you use 
explisit and implisitt transaction handling ... And you don't have to call endTransaction()
yourself.

AND you also can introduce automatically rollback when an exception happens in your DAO class
e.g. very
nice feature... So you don't have to program a rollback yourself each time, when you have
a write transaction.

Let me know if you want some code examples of dynamic proxy.


Take care,
Erlend Bjørge

Mime
View raw message