Hi Daniel,
Thank you very much for responding to the query. >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? Actually I was logging the time taken to get the Connection from pool and it was taking around 2300 milli seconds to get connection from pool after *initialSize* connections(10) are retrieved. I checked it for around 100 fetches in a span of 5 minutes as my *timeBetweenEvictionRunsMillis* was 60 and after each run of evictor thread *minIdle* should be validated. >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? Yes, I was unwrapping each connection before returning it using the below piece of code. con = ds.getConnection().unwrap(oracle.jdbc.OracleConnection.*class*); *return* con; As explained by you, this is where the problem was. I needed a OracleConnection in some parts of my application as I was creating ArrayDescriptor, which failed when I passed the proxy Connection. Now I am unwrapping the proxy Connection only when required and calling *con.close()* on the Proxy returned from the pool, not on the unwrapped connection. This fixed my issue J. Once again thanks for the clarifying my doubts and helping me resolving my issue. Best Regards Srikanth R Patlolla On Wed, Nov 13, 2013 at 5:42 PM, Daniel Mikusa <dmik...@gopivotal.com>wrote: > 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 > >