Re: Database Connection Pooling initialization with dbcp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chris, On 9/9/2009 12:01 PM, Chris Wiley wrote: My question is this: Am I to assume that I need to OPEN and CLOSE x number of connections in the init section of the servlet to load the pool with live connections? No, this can be done with configuration. Unless you have changed your config, Tomcat uses commons-dbcp whose configuration reference can be found here: http://commons.apache.org/dbcp/configuration.html I think you want to take a look at the initialSize and minIdle parameters. Is there any reason why you absolutely need those connections to all be available right away? Laziness can sometimes be beneficial... :) - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkqpNdkACgkQ9CaO5/Lv0PAZQACeMOlUmLcr/9eTfUTxeNuv1mpu 0pkAoLg8687dcxFcYa/Ki1aeApv8xELL =WerZ -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Database Connection Pooling initialization with dbcp
Chris, I think I am looking at it the wrong way. I have been looking at it as a collection of static connections that are managed. i.e., putting 8 connections in an array or hashtable and grabbing them when needed and letting something check them every so often to keep them refreshed. Earlier in the post, Ziggy suggested that the pooling mechanism is a dynamic caching system; and looking at it as a caching system is starting to make more sense to me. The api makes more sense from this perspective. where it just keeps x number of connections around at any given point in time. I don't have to have connections from the get go, but it would be nice. That means the first person to hit the app has to take the hit on the creation of the first connection or two. Which, I suppose isn't bad. As far as the initialSize parameter, do I just append those to the datasource under the Resource element in the web.xml? and will that actually create some initial connections in the pool? Do I need to set up init-params and get them that way? The thing about the configuration reference is that I could not really tell where in the config to put those various elements, maybe it doesn't matter. -Chris -Original Message- From: Christopher Schultz [mailto:ch...@christopherschultz.net] Sent: Thursday, September 10, 2009 12:23 PM To: Tomcat Users List Cc: chriswile...@gmail.com Subject: Re: Database Connection Pooling initialization with dbcp -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chris, On 9/9/2009 12:01 PM, Chris Wiley wrote: My question is this: Am I to assume that I need to OPEN and CLOSE x number of connections in the init section of the servlet to load the pool with live connections? No, this can be done with configuration. Unless you have changed your config, Tomcat uses commons-dbcp whose configuration reference can be found here: http://commons.apache.org/dbcp/configuration.html I think you want to take a look at the initialSize and minIdle parameters. Is there any reason why you absolutely need those connections to all be available right away? Laziness can sometimes be beneficial... :) - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkqpNdkACgkQ9CaO5/Lv0PAZQACeMOlUmLcr/9eTfUTxeNuv1mpu 0pkAoLg8687dcxFcYa/Ki1aeApv8xELL =WerZ -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Database Connection Pooling initialization with dbcp
From: Chris Wiley [mailto:cwile...@comcast.net] Subject: RE: Database Connection Pooling initialization with dbcp As far as the initialSize parameter, do I just append those to the datasource under the Resource element in the web.xml? Set the values as additional attributes in the Resource element. E.g., Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource initialSize=10 maxActive=100 maxIdle=30 minIdle=10 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ will that actually create some initial connections in the pool? It's broken if it doesn't. You probably also want to specify validationQuery and testOnBorrow, in case the DB (or intervening firewall) drops connections on you. - 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
Database Connection Pooling initialization with dbcp
Hello, I have a web app I have developed under Tomcat 6.0.18 and have added in the dbcp system. As it stands now, It wants to make connections only after the first request to the app. I want the dbcp system to initialize x number of connections on app/server startup. I know if I want to initialize things on startup I include the load-on-startup1/load-on-startup in the web.xml for the app; which will load the servlet and execute what's in the init method. My question is this: Am I to assume that I need to OPEN and CLOSE x number of connections in the init section of the servlet to load the pool with live connections? Otherwise, I don't see how it will create those connections and load the pool on startup. I seem to be missing or overlooking a method call in the api that will actually load the pool with live connections. Not sure if it makes a difference, but I also have the dbcp being set up in a ServletContextListener. Any Help is greatly appreciated, have spent to much time on this trying to get it to work like I want or as it's supposed to. Thanks! Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Database Connection Pooling initialization with dbcp
Im not an expert on this but i thought that the pool will cache connections that you have created. Maybe someone can clarify this. Have a look at this http://onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html?page=2 On Wed, Sep 9, 2009 at 9:01 AM, Chris Wiley cwile...@comcast.net wrote: Hello, I have a web app I have developed under Tomcat 6.0.18 and have added in the dbcp system. As it stands now, It wants to make connections only after the first request to the app. I want the dbcp system to initialize x number of connections on app/server startup. I know if I want to initialize things on startup I include the load-on-startup1/load-on-startup in the web.xml for the app; which will load the servlet and execute what's in the init method. My question is this: Am I to assume that I need to OPEN and CLOSE x number of connections in the init section of the servlet to load the pool with live connections? Otherwise, I don't see how it will create those connections and load the pool on startup. I seem to be missing or overlooking a method call in the api that will actually load the pool with live connections. Not sure if it makes a difference, but I also have the dbcp being set up in a ServletContextListener. Any Help is greatly appreciated, have spent to much time on this trying to get it to work like I want or as it's supposed to. Thanks! Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org