Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 71825 invoked from network); 6 Oct 2003 18:23:11 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 Oct 2003 18:23:11 -0000 Received: (qmail 17139 invoked by uid 500); 6 Oct 2003 18:22:56 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 17109 invoked by uid 500); 6 Oct 2003 18:22:56 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 17090 invoked from network); 6 Oct 2003 18:22:56 -0000 Received: from unknown (HELO shareowner.com) (66.46.24.147) by daedalus.apache.org with SMTP; 6 Oct 2003 18:22:56 -0000 Received: from exchange.int.shareowner.com (gw.shareowner.com [66.46.24.163]) by shareowner.com (Postfix) with ESMTP id 0F87023606 for ; Mon, 6 Oct 2003 14:23:03 -0400 (EDT) Received: by exchange.int.shareowner.com with Internet Mail Service (5.5.2656.59) id ; Mon, 6 Oct 2003 14:22:59 -0400 Message-ID: From: Phillip Qin To: 'Jakarta Commons Users List' Subject: RE: DBCP general setup and use Date: Mon, 6 Oct 2003 14:22:58 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C38C36.DE8AB220" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C38C36.DE8AB220 Content-Type: text/plain Dirk, When you update dbcp website, be sure to fix the link of "Source (Browse)". It's pointing to pool cvs currently. -----Original Message----- From: Dirk Verbeeck [mailto:dirk.verbeeck@pandora.be] Sent: October 2, 2003 6:33 PM To: Jakarta Commons Users List Subject: Re: DBCP general setup and use Hi Daryl, There is a preview website of the v1.1 version you will find more info about the various parameters: http://cvs.apache.org/~dirkv/dbcp/configuration.html Constructing your own datasource can be a bit tricky, take a look at BasicDataSource as example http://cvs.apache.org/viewcvs/jakarta-commons/dbcp/src/java/org/apache/commo ns/dbcp/BasicDataSource.java You might also want to look at the Developers guide: http://cvs.apache.org/~dirkv/dbcp/guide/classdiagrams.html The official website will be updated in a couple of days, then you will find all the info there as well. A few pointers about your current code: The properties you give to the DriverManagerConnectionFactory are the properties for your database driver. In your case only "user" & "password". The driver itself should be loaded by a Class.forName(driver); as you would do without a pool. The other settings you have to do using the setters on config, connectionPool and dataSource. Mapping of your old configuration: * max connections - the maximum number of connections allowed out => connectionPool maxActive * min connections - the number of connections to open upon start up => minIdle (not only at startup but always) (needs timeBetweenEvictionRunsMillis configuration) * max checkout - the number of seconds a connection is allowed out of the pool => AbandonedConfig removeAbandonedTimeout * connection reset time - a possibly DbConnectionBroker-specific recycle time (defaults to one day) => connectionPool minEvictableIdleTimeMillis (needs timeBetweenEvictionRunsMillis configuration) When you create a "PoolableConnectionFactory" it registers itself on the "connectionPool" using the setFactory method so you just need to create one at make it all work. Be sure to use the v1.1 release candidate: http://cvs.apache.org/~dirkv/builds/ Documentation improvements are welcome, there is still room for improvement ;-) Cheers Dirk Daryl Stultz wrote: > Hi Folks, > I'm trying to convert my database handling from DbConnectionBroker to > DBCP. > Here is my code for creating datasources. I'm a bit unsure how to > configure the whole thing - the docs are a bit weak. > > AbandonedConfig config = new AbandonedConfig(); > config.setLogAbandoned(true); > config.setRemoveAbandoned(true); > config.setRemoveAbandonedTimeout((new Double(maxConnTime)).intValue()); > > ObjectPool connectionPool = new GenericObjectPool(null); > > Properties props = new Properties(); > Object drivObj = Class.forName(driver); > props.setProperty("driverClassName", driver); > props.setProperty("driverName", driver); > props.setProperty("user", login); > props.setProperty("password", password); > props.setProperty("maxActive", Integer.toString(maxConn)); > props.setProperty("maxIdle", Integer.toString(minConn)); > props.setProperty("maxWait", Integer.toString(maxCheckout)); > > ConnectionFactory connectionFactory = new > DriverManagerConnectionFactory(server, props); > PoolableConnectionFactory poolableConnectionFactory = new > PoolableConnectionFactory(connectionFactory, connectionPool, null, null, > false, true, config); > > PoolingDataSource dataSource = new PoolingDataSource(connectionPool); > > > I don't really understand the three properties on AbandonedConfig. I also > can't find any official description of the various properties I am setting > here (props). Basically my current config files specify: > > driver - the class name > server - the connection string > user > password > max connections - the maximum number of connections allowed out > min connections - the number of connections to open upon start up > max checkout - the number of seconds a connection is allowed out of the > pool > connection reset time - a possibly DbConnectionBroker-specific recycle > time (defaults to one day) > > Aside from the first four, I'm not exactly sure where the others plug in. > maxActive seems to map to my max connections. Does maxIdle map to min > connections? What is maxWait? > > How do I set up logging? Can I specify a file to log to? Append or > overwrite? A log level? I can't get myself to trust this pooler if I can't > monitor it. > > The examples (including mine) all spin up an instance of > PoolableConnectionFactory but then don't use it. If I take it out, it > doesn't work. Is there a side-effect to creating this instance? Why isn't > a static method? What might I want to do with the instance? > > Also, note that I needed to put in the line above > Object drivObj = Class.forName(driver); > in order for it to work with Microsoft SQLServer. Any idea why? The > driverClassName and driverName properties didn't seem to help - it throws > a "No suitable driver" error without this line. > > Thanks for any help. > > Daryl Stultz > _____________________________________ > 6 Degrees Software and Consulting, Inc. > http://www.6degrees.com > mailto:daryl@6degrees.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org ------_=_NextPart_001_01C38C36.DE8AB220--