Re: Reg: Connection pool stats

2013-11-14 Thread Daniel Mikusa
On Nov 14, 2013, at 2:23 AM, Anu Prab anupr...@gmail.com wrote:

 On Nov 11, 2013, at 12:59 AM, Anu Prab anupr...@gmail.com wrote:
 
 On Nov 7, 2013, at 11:58 PM, Anu Prab anupr...@gmail.com wrote:
 
 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
 
 timeBetweenEvictionRunsMillis=180
 
 validationQuery=SELECT 1 from dual
 
 validationInterval=3
 
 maxActive=50
 
minIdle=4
 
 maxIdle=4
 
 maxWait=1
 
   initialSize=4
 
   removeAbandonedTimeout=60
 
removeAbandoned=true
 
logAbandoned=false
 
 
 What factory are you using?  It's important to share.  Without it we
 don't
 know which pool you're using.
 
 A customized factory which extends org.apache.tomcat.jdbc.pool.
 DataSourceFactory
 Few minutes, not sure of the exact timing. Yes, all are 0.
 
 Also, what happens when you try to get a connection after the pool count
 has dropped to 0?  Does it get a new connection?  Does it hang waiting?
 Does it generate any error messages?
 
 Is there any reason why you might be getting disconnected from the
 database side or from a firewall in between your application and the
 database?
 
 I can still get newer connections even after the count drops to 0.
 
 
 Hi,
 
 Also, when I enabled logAbandoned as you suggested, I see this exception
 after about 17-18 minutes.
 
 org.apache.tomcat.jdbc.pool.ConnectionPool abandon
 WARNING: Connection has been abandoned
 PooledConnection[oracle.jdbc.driver.T4CConnection@2726965a
 ]:java.lang.Exception
   at
 
 org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1065)
   at
 
 org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:707)
   at
 
 org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
   at
 
 org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)
 
 This explains the behavior that you're seeing.  It appears that your
 connections are being flagged as abandoned and thus removed from the pool.
 
 Take a look at the generated stack trace and see what part of your code is
 holding onto the connection.  This could be legitimate, in the case where
 you have a long running process (like a batch job) or it could be a code
 error (like you don't have proper try..catch..finally blocks setup to
 close connections).
 
 Dan
 
 Hi,
 
 The problem that we are facing now is that the connections are showing idle
 when they are not being used. When we queried the gv$session table in the
 database, we could still find the entry of this inactive/idle connection.

Ok, what does the pool think?  Have you looked at the active  idle count there 
(like with jconsole)?  The reason I ask is because based on your configuration 
you should see some idle connections in the pool.

 They are not being recycled after the min idle and eviction time had
 passed.

How are you making this determination?  It would be helpful if you could post 
the active  idle counts from your pool when it's in this state so that we can 
determine if it should actually be evicting idle threads.

Based on the configuration you listed above, I would not expect the pool to 
evict a connection because it's been idle too long.  You have both minIdle and 
maxIdle set to four and the idle check only runs when you have more than 
minIdle idle connections in your pool.  Because you also have maxIdle set to 
four I don't think you'll ever have more than four idle connections in your 
pool.  This is because when connections are returned to the pool, the pool 
checks to see if that connection would push it over maxIdle.  If it would then 
the connection is discarded instead of being returned to the pool.

Here's an example:

1.) You start with 4 connections in the pool (that's your initialSize).
2.) The pool cleaner thread runs and no idle check is performed because you 
don't have more than minIdle idle connections in the pool.
3.) Your application take a connection.
4.) The pool cleaner thread runs again.  There is still no idle check is 
performed, because you don't have more than minIdle idle connections in the 
pool.
5.) Your application takes four more connections.  This causes the pool to 
create a fifth connection.
6.) The pool cleaner thread runs.  Still no idle checks being performed.  This 
time because there are no idle connections.
7.) Your application returns four of the connections.  

Re: Reg: Connection pool stats

2013-11-13 Thread Anu Prab
On Nov 11, 2013, at 12:59 AM, Anu Prab anupr...@gmail.com wrote:

 On Nov 7, 2013, at 11:58 PM, Anu Prab anupr...@gmail.com wrote:

 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

  timeBetweenEvictionRunsMillis=180

  validationQuery=SELECT 1 from dual

  validationInterval=3

  maxActive=50

 minIdle=4

  maxIdle=4

  maxWait=1

initialSize=4

removeAbandonedTimeout=60

 removeAbandoned=true

 logAbandoned=false


 What factory are you using?  It's important to share.  Without it we
don't
 know which pool you're using.

 A customized factory which extends org.apache.tomcat.jdbc.pool.
 DataSourceFactory
 Few minutes, not sure of the exact timing. Yes, all are 0.

 Also, what happens when you try to get a connection after the pool count
 has dropped to 0?  Does it get a new connection?  Does it hang waiting?
 Does it generate any error messages?

 Is there any reason why you might be getting disconnected from the
 database side or from a firewall in between your application and the
 database?

 I can still get newer connections even after the count drops to 0.


 Hi,

 Also, when I enabled logAbandoned as you suggested, I see this exception
 after about 17-18 minutes.

 org.apache.tomcat.jdbc.pool.ConnectionPool abandon
 WARNING: Connection has been abandoned
 PooledConnection[oracle.jdbc.driver.T4CConnection@2726965a
 ]:java.lang.Exception
at

org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1065)
at

org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:707)
at

org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
at

org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)

 This explains the behavior that you're seeing.  It appears that your
connections are being flagged as abandoned and thus removed from the pool.

Take a look at the generated stack trace and see what part of your code is
holding onto the connection.  This could be legitimate, in the case where
you have a long running process (like a batch job) or it could be a code
error (like you don't have proper try..catch..finally blocks setup to
close connections).

 Dan

Hi,

The problem that we are facing now is that the connections are showing idle
when they are not being used. When we queried the gv$session table in the
database, we could still find the entry of this inactive/idle connection.
They are not being recycled after the min idle and eviction time had
passed.
We think this is happening because the validation query runs and makes the
query unidle and hence the eviction does not pick it up. Is it so? Please
help.

-Anu


Re: Reg: Connection pool stats

2013-11-11 Thread Daniel Mikusa
On Nov 11, 2013, at 12:59 AM, Anu Prab anupr...@gmail.com wrote:

 On Nov 7, 2013, at 11:58 PM, Anu Prab anupr...@gmail.com wrote:
 
 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
 
 What factory are you using?  It's important to share.  Without it we don't
 know which pool you're using.
 
 A customized factory which extends org.apache.tomcat.jdbc.pool.
 DataSourceFactory
 Few minutes, not sure of the exact timing. Yes, all are 0.
 
 Also, what happens when you try to get a connection after the pool count
 has dropped to 0?  Does it get a new connection?  Does it hang waiting?
 Does it generate any error messages?
 
 Is there any reason why you might be getting disconnected from the
 database side or from a firewall in between your application and the
 database?
 
 I can still get newer connections even after the count drops to 0.
 
 
 Hi,
 
 Also, when I enabled logAbandoned as you suggested, I see this exception
 after about 17-18 minutes.
 
 org.apache.tomcat.jdbc.pool.ConnectionPool abandon
 WARNING: Connection has been abandoned
 PooledConnection[oracle.jdbc.driver.T4CConnection@2726965a
 ]:java.lang.Exception
at
 org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1065)
at
 org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:707)
at
 org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
at
 org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)

This explains the behavior that you're seeing.  It appears that your 
connections are being flagged as abandoned and thus removed from the pool.  

Take a look at the generated stack trace and see what part of your code is 
holding onto the connection.  This could be legitimate, in the case where you 
have a long running process (like a batch job) or it could be a code error 
(like you don't have proper try..catch..finally blocks setup to close 
connections).

Dan

 
 -Anu


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



Re: Reg: Connection pool stats

2013-11-10 Thread Anu Prab
On Nov 7, 2013, at 11:58 PM, Anu Prab anupr...@gmail.com wrote:

 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

What factory are you using?  It's important to share.  Without it we don't
know which pool you're using.

A customized factory which extends
org.apache.tomcat.jdbc.pool.DataSourceFactory

  username=username
  password=password
  driverClassName=oracle.jdbc.OracleDriver
 url=url
  timeBetweenEvictionRunsMillis=180
  validationQuery=SELECT 1 from dual
  validationInterval=3
  maxActive=50
  minIdle=4
  maxIdle=4
  maxWait=1
  initialSize=4
  removeAbandonedTimeout=60
  removeAbandoned=true
  logAbandoned=false

You should enable this so you're alerted if your application is not
properly returning connections.

  minEvictableIdleTimeMillis=
60
  initSQL=initSQL

Is this SQL valid?  If for some reason this SQL was failing, it would cause
your connection count to go to zero.  Same with the validation query,
although that looks OK.

  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.

How long does it take for the size to go to zero?  When it does, what do
the active and idle counts show?  Are they zero too?

Few minutes, not sure of the exact timing. Yes, all are 0.

 Also, what happens when you try to get a connection after the pool count
has dropped to 0?  Does it get a new connection?  Does it hang waiting?
 Does it generate any error messages?

Is there any reason why you might be getting disconnected from the
database side or from a firewall in between your application and the
database?

I can still get newer connections even after the count drops to 0.

-Anu


Re: Reg: Connection pool stats

2013-11-10 Thread Anu Prab
On Nov 7, 2013, at 11:58 PM, Anu Prab anupr...@gmail.com wrote:

 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

What factory are you using?  It's important to share.  Without it we don't
know which pool you're using.

A customized factory which extends org.apache.tomcat.jdbc.pool.
DataSourceFactory
Few minutes, not sure of the exact timing. Yes, all are 0.

 Also, what happens when you try to get a connection after the pool count
has dropped to 0?  Does it get a new connection?  Does it hang waiting?
 Does it generate any error messages?

Is there any reason why you might be getting disconnected from the
database side or from a firewall in between your application and the
database?

I can still get newer connections even after the count drops to 0.


Hi,

Also, when I enabled logAbandoned as you suggested, I see this exception
after about 17-18 minutes.

org.apache.tomcat.jdbc.pool.ConnectionPool abandon
WARNING: Connection has been abandoned
PooledConnection[oracle.jdbc.driver.T4CConnection@2726965a
]:java.lang.Exception
at
org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1065)
at
org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:707)
at
org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
at
org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)

-Anu


Re: Reg: Connection pool stats

2013-11-08 Thread Daniel Mikusa
On Nov 7, 2013, at 11:58 PM, Anu Prab anupr...@gmail.com wrote:

 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

What factory are you using?  It's important to share.  Without it we don't know 
which pool you're using.

  username=username
  password=password
  driverClassName=oracle.jdbc.OracleDriver
  url=url
  timeBetweenEvictionRunsMillis=180
  validationQuery=SELECT 1 from dual
  validationInterval=3
  maxActive=50
  minIdle=4
  maxIdle=4
  maxWait=1
  initialSize=4
  removeAbandonedTimeout=60
  removeAbandoned=true
  logAbandoned=false

You should enable this so you're alerted if your application is not properly 
returning connections.

  minEvictableIdleTimeMillis=60
  initSQL=initSQL

Is this SQL valid?  If for some reason this SQL was failing, it would cause 
your connection count to go to zero.  Same with the validation query, although 
that looks OK.

  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.

How long does it take for the size to go to zero?  When it does, what do the 
active and idle counts show?  Are they zero too?

Also, what happens when you try to get a connection after the pool count has 
dropped to 0?  Does it get a new connection?  Does it hang waiting?  Does it 
generate any error messages?

Is there any reason why you might be getting disconnected from the database 
side or from a firewall in between your application and the database?

Dan

 
 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


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



Re: Reg: Connection pool stats

2013-11-07 Thread Daniel Mikusa
On Nov 7, 2013, at 2:07 AM, Anu Prab anupr...@gmail.com wrote:

 Hi,
 
 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.

 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.

 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?

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?

Dan

 -Anu


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



Re: Reg: Connection pool stats

2013-11-07 Thread Anu Prab
 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=180
  validationQuery=SELECT 1 from dual
  validationInterval=3
  maxActive=50
  minIdle=4
  maxIdle=4
  maxWait=1
  initialSize=4
  removeAbandonedTimeout=60
  removeAbandoned=true
  logAbandoned=false
  minEvictableIdleTimeMillis=60
  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


Reg: Connection pool stats

2013-11-06 Thread Anu Prab
Hi,

I am using Tomcat 7.0.42 and Tomcat jdbc pool. Once the pool is created
with the default configuration, I obtained few connections from this pool.
But after certain amount of time,

*dataSource.getSize*() shows the size as 0! Is this the expected
behavior? Please help me understand what is happening.

Thanks in advance.

-Anu


Reg: Connection pool stats

2013-11-06 Thread Anu Prab
Hi,

I am using Tomcat 7.0.42 and Tomcat jdbc pool. Once the pool is created
with the default configuration, I obtained few connections from this pool.

But after certain amount of time, dataSource.getSize() shows the size as 0!
Is this the expected behavior? Please help me understand what is happening.

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!
-Anu


Connection pool stats

2010-03-15 Thread Dhiren Bhatia
I've configured my DB connection pool as follows:

context.xml

Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource

maxActive=100 maxIdle=30 maxWait=1 username=xxx

password=xxx driverClassName=com.mysql.jdbc.Driver

url=jdbc:mysql://a.b.c:3306/Test removeAbandoned=true

removeAbandonedTimeout=60 logAbandoned=true /


web.xml


resource-ref

descriptionDB Connection/description

res-ref-namejdbc/myserver/res-ref-name

res-typejavax.sql.DataSource/res-type

res-authContainer/res-auth

/resource-ref


In my code, I use a javax.sql.DataSource object to get connections and call
connection.close() to return connections.


How do I get stats on the connection pool? I would like to check how many
connections are active/idle at any point in time.


Thanks,

Dhiren


Re: Connection pool stats

2010-03-15 Thread Mark Shifman
You can cast your datasource object to be a BasicDataSource
then the javadoc gives you all kinds of things you can get.
like getNumActive(), getNumIdle() etc
(for dbcp 1.3)
http://commons.apache.org/dbcp/api-1.3/index.html



Dhiren Bhatia wrote:
 I've configured my DB connection pool as follows:
 
 context.xml
 
 Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource
 
 maxActive=100 maxIdle=30 maxWait=1 username=xxx
 
 password=xxx driverClassName=com.mysql.jdbc.Driver
 
 url=jdbc:mysql://a.b.c:3306/Test removeAbandoned=true
 
 removeAbandonedTimeout=60 logAbandoned=true /
 
 
 web.xml
 
 
 resource-ref
 
 descriptionDB Connection/description
 
 res-ref-namejdbc/myserver/res-ref-name
 
 res-typejavax.sql.DataSource/res-type
 
 res-authContainer/res-auth
 
 /resource-ref
 
 
 In my code, I use a javax.sql.DataSource object to get connections and call
 connection.close() to return connections.
 
 
 How do I get stats on the connection pool? I would like to check how many
 connections are active/idle at any point in time.
 
 
 Thanks,
 
 Dhiren
 

-- 
 Mark Shifman MD. Ph.D.
 Yale Center for Medical Informatics
 Phone (203)737-5219
 mark.shif...@yale.edu

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



RE: Connection pool stats

2010-03-15 Thread Caldarale, Charles R
 From: Dhiren Bhatia [mailto:dhiren.for...@gmail.com]
 Subject: Connection pool stats
 
 How do I get stats on the connection pool? I would like to check how
 many connections are active/idle at any point in time.

This may help:
http://lambdaprobe.org/d/index.htm

An example of its display for a data source:
http://lambdaprobe.org/d/screenshots/full/datasources.png

You can also programmatically grab statistics for just about anything in your 
webapp with this:
http://moskito.anotheria.net/

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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



Re: Connection pool stats

2010-03-15 Thread Dhiren Bhatia
Hi Mark,

That won't work because Tomcat creates an instance of
org.apache.tomcat.dbcp.dbcp.BasicDataSource which cannot be cast to
org.apache.commons.dbcp.BasicDataSource.

I need to keep the code generic (to run in other containers), so I can't use
org.apache.tomcat.dbcp.dbcp.BasicDataSource in the code to receive the
object Tomcat creates.

Dhiren

On Mon, Mar 15, 2010 at 11:22 AM, Mark Shifman mark.shif...@yale.eduwrote:

 You can cast your datasource object to be a BasicDataSource
 then the javadoc gives you all kinds of things you can get.
 like getNumActive(), getNumIdle() etc
 (for dbcp 1.3)
 http://commons.apache.org/dbcp/api-1.3/index.html



 Dhiren Bhatia wrote:
  I've configured my DB connection pool as follows:
 
  context.xml
 
  Resource name=jdbc/myserver auth=Container
 type=javax.sql.DataSource
 
  maxActive=100 maxIdle=30 maxWait=1 username=xxx
 
  password=xxx driverClassName=com.mysql.jdbc.Driver
 
  url=jdbc:mysql://a.b.c:3306/Test removeAbandoned=true
 
  removeAbandonedTimeout=60 logAbandoned=true /
 
 
  web.xml
 
 
  resource-ref
 
  descriptionDB Connection/description
 
  res-ref-namejdbc/myserver/res-ref-name
 
  res-typejavax.sql.DataSource/res-type
 
  res-authContainer/res-auth
 
  /resource-ref
 
 
  In my code, I use a javax.sql.DataSource object to get connections and
 call
  connection.close() to return connections.
 
 
  How do I get stats on the connection pool? I would like to check how many
  connections are active/idle at any point in time.
 
 
  Thanks,
 
  Dhiren
 

 --
  Mark Shifman MD. Ph.D.
  Yale Center for Medical Informatics
  Phone (203)737-5219
  mark.shif...@yale.edu

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