ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Rothenbacher <tc...@hotmail.com>
Subject RE: C3P0 configuration example for iBatis anyone?
Date Fri, 30 May 2008 11:50:44 GMT

Hi Clinton, sorry I didn't mean to offend you, it may well be by design but it definitely
is an issue in our situation. We have a firewall between the db and webserver which is closing
inactive connections when the app sits idle for a period of time. After the idle period, the
first person who attempts to logon to the website experiences a 15 minute lag while it waits
for the connection pool to deem the connection it selected out of the pool bad, recycle it
and start using the fresh connection. We are open to using any connection pool mechanism with
ibatis that has an option to test idle pooled connections and recycle them if they are deemed
bad on a configurable basis. See below for a log snippit, notice the timestamp delay between
when it started testing the connection and when it finally failed.
2008-05-24 21:12:55,720 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Checked out connection
15102369 from pool.2008-05-24 21:12:55,720 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Testing connection 15102369 ...2008-05-24 21:28:21,364 WARN  [com.ibatis.common.jdbc.SimpleDataSource]
Execution of ping query 'select 1 from DUAL' failed: Io exception: Connection timed out2008-05-24
21:28:21,365 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 15102369 is BAD: Io
exception: Connection timed out2008-05-24 21:28:21,365 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
A bad connection (15102369) was returned from the pool, getting another connection.2008-05-24
21:28:21,440 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Created connection 135206972008-05-24
21:28:21,460 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Testing connection 13520697 ...2008-05-24
21:28:21,463 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 13520697 is GOOD!2008-05-24
21:28:21,463 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Returned connection 13520697
to pool.
I am certainly open to trying oracle.jdbc.pool.OracleConnectionPoolDataSource - any suggestions
for a datasource that has a feature to test idle connections on a configurable basis and recycle
them (hopefully before a user notices a problem) would be great. We only saw SimpleDataSource
and DBCP as options in the ibatis documentation so that is what we have tried so far (well
we did try C3P0 without success and that is the reason for the post - hopefully to find someone
who has actually successfully implemented c3p0 or some other datasource that allows idle connection
testing/eviction). Richard, would you have an example SqlMapConfig.xml using this datasource
Thanks again.

Date: Thu, 29 May 2008 22:12:22 -0600From: clinton.begin@gmail.comTo: user-java@ibatis.apache.orgSubject:
Re: C3P0 configuration example for iBatis anyone?>> SimpleDatasource exhibits an issue
with pool.pingquery taking roughly 15min before a bad connection is deemed bad and removed
from the pool, there seems to be no reaper or evictor thread to test idle connections on a
regular basis as opposed to testing at checkout time. <<This is not an issue, it is
by design.  SimpleDataSource is a synchronous connection pool.  It does not spawn threads
for eviction or any other reason.  Why do you care when the connection is removed from the
pool?  Clinton
On Thu, May 29, 2008 at 9:34 PM, Anton Rothenbacher <tcr49@hotmail.com> wrote:

Greetings, the short story is that we have tried DBCP and SimpleDatasource with iBatis but
had some issues with each, we are connecting to an Oracle 10g database.  * SimpleDatasource
exhibits an issue with pool.pingquery taking roughly 15min before a bad connection is deemed
bad and removed from the pool, there seems to be no reaper or evictor thread to test idle
connections on a regular basis as opposed to testing at checkout time.* DBCP has an evictor
thread that can test and recycle bad connections on a regular basis but we were unable to
get any decent information in the log about it's idle connection test activity (not a huge
issue granted but we would like to see some detail when there is a bad connection so that
we can investigate what is going on). A third option that we are investigating is to try C3P0
to be used as a connection pool mechanism to be used by iBatis but I'm unable to find documentation
or examples on exactly how to configure SqlMapConfig.xml/SqlMapConfig.properties to make it
work. I found the following link that suggests it is definitely possible but I'm not following
exactly how to configure this.  http://www.mail-archive.com/user-java@ibatis.apache.org/msg07957.html=================================
On 2/28/07, Clinton Begin <[EMAIL PROTECTED]> wrote:Absolutely. You can use any DataSource
implementation you like. All youneed to do is build a DataSourceFactory and pass the fully
qualifiedclassname (or type alias) into the datasource type in the <dataSource>element
of your SqlMapConfig.xmlpublic interface DataSourceFactory {public void initialize(Map map);public
DataSource getDataSource();}ClintonOn 2/28/07, JoeSmith < [EMAIL PROTECTED]> wrote:>>
Is it possible to use the c3p0 datasource/connection pool with> iBatis? Does anyone know
how this package compares to dbcp? Are there any> known issues or problems?=================================
Has anyone successfully used C3P0 datasource with ibatis? If so could you share an example
configuration (or point me to some docs) as to the proper config to swap out dbcp or simple
datasource with c3p0? It seems it shouldn't be difficult but google is not being my friend
in finding information on it. Does it require additional code in the app or just config changes
in the SqlMapConfig.xml?Thanks for any insight you can provide. 

Change the world with e-mail. Join the i'm Initiative from Microsoft.
Make every e-mail and IM count. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ MakeCount
View raw message