• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MaxActive database connection parameter doesn't work

 
Luke Rossi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have a problem with datasource configuration.

I have a Tomcat 7 with Java 7 and a Quartz web application.
This application has a datasource configured:



With maxActive = 3 I expected to see no more than 3 connection opened. Instead of this, I see a new connection opened every time a Quartz Job starts, untill 8 connection (don't know if this is the default limit).

So it seems this parameter is not considered, but other yes, because the connection to database is correct so username, password etc... are ok.

Can you help me please?

thanks
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running this via Eclipse (WTP)?
I seem to remember it uses its own values for those things...
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch!

Quartz has its own persistent store options for the schedules it runs. So unless you've specifically told Quartz to use pool "jdbc/name", then your configuration for the application connection pool would not apply.

Tomcat 7 complicates things, since you can either use the traditional Apache DBCP pool manager or the new Tomcat DBCP pool manager. I don't know about the Apache DBCP manager, but I just took a peek at the Tomcat DBCP manager, and what it actually does is query maxActive when a pool Connection is requested. So in theory, more connections could physically exist for some reason even though Tomcat will only actually assign maxActive or less connections at one time.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Are you running this via Eclipse (WTP)?
I seem to remember it uses its own values for those things...


Good point. Actually, WTP makes a (incomplete) clone of the Tomcat settings to use when it launches Tomcat. And it doesn't update from your primary settings automatically, so WTP may not actually be using your coded maxConnections.

It is, in fact, a royal pain, which is why I prefer to use the Mongrel (sysdeo) Tomcat plugin for Eclipse instead of WTP.
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:
It is, in fact, a royal pain, which is why I prefer to use the Mongrel (sysdeo) Tomcat plugin for Eclipse instead of WTP.


I have a completely separate Tomcat instance that I deploy to, and attach a debugger.
I always had too many inconsistencies with inbuilt servers.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try Mongrel. You install Tomcat for stand-alone operation, point the Mongrel plugin to it and it will automatically handle start/stop/restart and debug connections.

It runs just like what you're doing, but automates the process, so the standard stand-alone config files are what actually gets used and not some stale incomplete copy.
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Try Mongrel. You install Tomcat for stand-alone operation, point the Mongrel plugin to it and it will automatically handle start/stop/restart and debug connections.

It runs just like what you're doing, but automates the process, so the standard stand-alone config files are what actually gets used and not some stale incomplete copy.


Ta.
I'll try and remember the next time I'm in a place that has a Tomcat set up I can hook into.
Current client has their own setup.

The joy of contracting. I get to witness the many and varied ways people can set up their systems and dev environments.
 
Luke Rossi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you replies, but it' was nothing related to quartz. It was a problem of factory org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory

using org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory (replacing the originial tomcat 7 jar) it works

Don't know why, but it works. With org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory even if initialSize was set to 8, only one was instantiated. Simply replacinig with org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory, 8 were instantiated
 
Luke Rossi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I talked before time...

initialSize is correctly instantied.

maxActive is not considered, so a new connection is always opened every time...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic