• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get pool information in java using BasicDataSource object  RSS feed

 
mohammad shadab
Ranch Hand
Posts: 54
Eclipse IDE Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to get the number of active connections using BasicDataSource object like following



Using above code , I am expecting following output



But always i do get zero as NumActive and NumIdle. Please suggest how can we get these .

Thanks
Shadab.
 
L Foster
Ranch Hand
Posts: 222
12
Android AngularJS Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Mohammad:
You've introduced me to something I had not heard of prior.  Thanks for that.

I looked up the javadoc on this BasicDataSource object.  If I were trying to use this, I might first ask myself, "have I given proper parameters?"  To answer that, I would probe for other things even more obvious.  I would call "getUrl()", which you just set, and see if it matched, for instance.

Also, I would test my assumptions about what "idle" and "active" means.  I would do that by calling "getMaxActive()" and "getMaxIdle()".  Further, if that also gave me zero, I might wonder if I really need to get a connection to the datasource before any of this is reported.

One more thought: I have been using datasources supplied by servers for many years.  Usually that comes down to configuration with XML files or some such (on the filesystem used by the server, and housed in some deployment directory), and then in code either doing a JNDI lookup or injecting a factory of some kind.  Since I have seen that these settings have to be supplied somehow, I would be wondering if active and idle connections had to be configured prior to use.  I see that you have established a driver, URL and user/pass, but I do not see anything that dictates anything else about this data source.

HTH
 
mohammad shadab
Ranch Hand
Posts: 54
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically i am using dbcp connection pooling , And in order to see the statistics of my app i want to know following parameters any point from the dbcp pool :-

1) Number of active connections
2) number of idle connections

Any idea will be great.

Thanks
Shadab.
 
Knute Snortum
Sheriff
Posts: 3436
85
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried any of the things L Foster suggested?  What happened when you did?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!