On Nov 13, 2013, at 4:01 AM, Srikanth <gaadi...@gmail.com> wrote:

> Hi,
> 
> I am using the below configuration for creating a datasource in Tomcat
> 7.0.42. And the backend database is Oracle 10g.
> 
> <Resource name="jdbc/crd"
>  auth="Container"
>  type="javax.sql.DataSource"
>  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>  driverClassName="oracle.jdbc.driver.OracleDriver"
>  username="xxxx"
>  password="xxxx"
>  url="jdbc:oracle:thin:@xxxx:xxxx:xxxx"
>  initialSize="10"
>  minIdle="20"
>  maxIdle="40"
>  maxActive="100"
>  maxWait="60000"
>  validationQuery="SELECT 1 FROM DUAL"
>  validationInterval="300000"
>  testOnBorrow="true"
>  testOnReturn="true"
>  testWhileIdle="true"
>  minEvictableIdleTimeMillis="1800000"
>  timeBetweenEvictionRunsMillis="60000"
>  removeAbandoned="true"
>  removeAbandonedTimeout="600"
>  logAbandoned="true"
>  jmxEnabled="true"
>  jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
> org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;
> org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx(threshold=10000)">
> </Resource>
> 
> Now the problem is whenever I try to get a connection from pool, it is
> creating a new connection and returning back.

How do you know it is creating a new connection?  Are you monitoring the number 
of active / idle connections in the pool?  What numbers do you see?

> minIdle connections are not maintained in the pool

minIdle is only enforced if you have more than minIdle connections in the pool. 
 For example, if you have 10 connections idle in the pool and minIdle is 20, 
the idle check will not run.  If you have 30 connections idle in the pool and 
minIdle is 20 then the idle check will run.  In addition, the idle check will 
only remove idle connections from the pool.  It will not add connections to the 
pool.

> and when I call con.close(), the connections are getting closed instead of 
> returning to the
> pool (closing the connection in finally block by passing con object to a
> different method)

This is unlikely as the pool returns a proxy that wraps the actual connection.  
Unless you are specifically accessing the underlying JDBC connection, what you 
are indicating shouldn't happen.

   
http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Getting_the_actual_JDBC_connection

Do you have a code example of what you're doing?

> 
> Getting connection is taking considerable amount of time in my application,
> so I need the tomcat server to maintain the idle connections at any point
> of time.

Again, how do you know it is not maintaining idle connections.  Do you see any 
messages in the logs?

Dan

> Kindly help me resolve the issue.
> 
> Thanks
> Srikanth


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to