Vijay,

I don't get what you are trying to do.

Why are you getting a DataSource from JNDI and then using the settings
from it to create an ObjectPool? Shouldn't it be sufficient to simply
do:

Connection c = dsINTLDB.getConnection();
// use connection.
c.close();

On 3/13/06, Vijay Anjur <[EMAIL PROTECTED]> wrote:
> I am having trouble with dbcp connection pooling with JTDS driver.
>
> When I close the connection, pool never seem to shrink after the idle time
> specified in server.xml has passed.
> When I check using GetNumIdle() method, it always shows zero, even after the
> connections are closed.Any Ideas?
>
>  Here is my server config & the code.
>
>  <Resource
>
>       name="jdbc/somedb"
>
>       auth="Container"
>
>       type="javax.sql.DataSource"
>
>       factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>
>       driverClassName="net.sourceforge.jtds.jdbc.Driver"
>
>       validationQuery="Select 1"
>
>       maxWait="6000"
>
>       username="username"
>
>       password="something"
>
>       testOnBorrow="true"
>
>       testOnReturn="false"
>
>       testWhileIdle="true"
>
>       url="jdbc:jtds:sqlserver://server:16778"
>
>       initialSize="8"
>
>       numTestsPerEvictionRun="6"
>
>       timeBetweenEvictionRunsMillis="10000"
>
>       minEvictableIdleTimeMillis="100000"
>
>       removeAbandoned="true"
>
>       removeAbandonedTimeout="300"
>
>       logAbandoned="true"
>
>       maxActive="20"
>
>       maxIdle="5"
>
>       minIdle="0"/>
>
>
>
>  Code snippet:
>
>    private InitialContext ic = null;
>
>    private Context envCtx = null;
>
>    private static DataSource dsINTLDB;
>
>    private static GenericObjectPool poolINTLDB;
>
>    private static PoolingDataSource pdsINTLDB;
>
>    private static BasicDataSource bdsINTLDB;
>
>
>
>   ic = new InitialContext();
>
>   envCtx = (Context) ic.lookup("java:comp/env");
>
>   dsINTLDB = (DataSource) envCtx.lookup("ds/somedb");
>
>
>
>  if (dsINTLDB != null)
>
>  {
>
>             bdsINTLDB = (BasicDataSource)dsINTLDB;
>
> ConnectionFactory cf1 = new DataSourceConnectionFactory(dsINTLDB);
>
> poolINTLDB = new GenericObjectPool(null,
>
>                                                bdsINTLDB.getMaxActive(),
>
>                                                (byte)1,
>
>                                                bdsINTLDB.getMaxWait(),
>
>                                                bdsINTLDB.getMaxIdle(),
>
>                                                bdsINTLDB.getMinIdle(),
>
>                                                bdsINTLDB.getTestOnBorrow(),
>
>                                                bdsINTLDB.getTestOnReturn(),
>
>
> bdsINTLDB.getTimeBetweenEvictionRunsMillis(),
>
>
> bdsINTLDB.getNumTestsPerEvictionRun(),
>
>
> bdsINTLDB.getMinEvictableIdleTimeMillis(),
>
>                                                bdsINTLDB.getTestWhileIdle()
> );
>
>
>
> PoolableConnectionFactory pcf1 = new PoolableConnectionFactory(cf1,
> poolINTLDB, null, null, false, true);
>
> pcf1.setValidationQuery(bdsINTLDB.getValidationQuery());
>
> pdsINTLDB = new PoolingDataSource(poolINTLDB);
>
> }
>
>
>
> Connection c = pdsINTLDB.getConnection();
>
> //use connection.
>
>
>
> c.close();


--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to