>> I am using Tomcat 7.0.42 and Tomcat jdbc pool.

>Just to be perfectly clear, how are you using this?  With a <Resource/>
tag in your Tomcat >configuration or are you creating the pool in your
code?  Either way, include the necessary >config or code which shows how
you've defined the pool.

The pool configuration is in context.xml. A sample of the config looks like
this:

   <Resource name="jdbc/name"
              auth="Container"
              type="javax.sql.DataSource"
              fairQueue="true"
              factory="<customized-factory>"
              username="<username>"
              password="<password>"
              driverClassName="oracle.jdbc.OracleDriver"
              url="<url>"
              timeBetweenEvictionRunsMillis="1800000"
              validationQuery="SELECT 1 from dual"
              validationInterval="30000"
              maxActive="50"
              minIdle="4"
              maxIdle="4"
              maxWait="10000"
              initialSize="4"
              removeAbandonedTimeout="60"
              removeAbandoned="true"
              logAbandoned="false"
              minEvictableIdleTimeMillis="600000"
              initSQL="<initSQL>"
              testOnBorrow="false"
              testOnReturn="false"
              testWhileIdle="true"
    />

>> Once the pool is created
>> with the default configuration, I obtained few connections from this
pool.

>Again, how are you obtaining connections?  Is this through JNDI or through
direct access by >code in your application?  An example would be helpful.

The connections are being obtained by the code through JNDI lookup. Here's
the code sample:

Context ctx = (Context)new InitialContext().lookup("java:comp/env/");
DataSource ds = (DataSource)ctx.lookup("jdbc/name");
ds.getConnection();


>> But after certain amount of time, dataSource.getSize() shows the size as
0!

>How are you determining this?  Are you looking at it in a debugger?  Do
you have a direct >reference to the data source in your code?  If so, can
you show an example?

I am doing a lookup for the data source in the code. The lookup example is
the same as above. The only addition is after getting the data source,
dataSource.getSize() is invoked.

>As a note, when used in Tomcat (i.e. you've configured it with a
<Resource/> tag) you should >use JMX to monitor pool statistics.  Of course
you can do this if you manually create the pool >(like in a public static
void main app), but you'll need to make sure JMX is correctly setup in
>your application.

>> Is this the expected behavior? Please help me understand what is
happening.

>We can certainly help you with this, but were going to need more info.
 See my other >comments.

>>
>>Thanks in advance.
>>
>> -Anu
>>
>>
>> Adding to the previous information, though the minIdle is set to a value
>> greater than 0, size of the pool, number of idle connections and number
of
>> active connections, all these are displayed as 0!

>Connection counts can legitimately go to zero under certain conditions.
 Are you seeing any >error or warning messages from the connection pool in
your logs?

No errors/warnings!

-Anu

>Dan

Reply via email to