Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 5555 invoked by uid 98); 31 Dec 2002 15:46:18 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 5536 invoked from network); 31 Dec 2002 15:46:16 -0000 Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142) by nagoya.betaversion.org with SMTP; 31 Dec 2002 15:46:16 -0000 Received: (qmail 49817 invoked by uid 500); 31 Dec 2002 15:45:00 -0000 Received: (qmail 49810 invoked from network); 31 Dec 2002 15:45:00 -0000 Received: from icarus.apache.org (63.251.56.143) by daedalus.apache.org with SMTP; 31 Dec 2002 15:45:00 -0000 Received: (qmail 77389 invoked by uid 1304); 31 Dec 2002 15:44:59 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 31 Dec 2002 15:44:59 -0000 Date: Tue, 31 Dec 2002 07:44:59 -0800 (PST) From: Rodney Waldhoff To: Jakarta Commons Users List Subject: Re: How to Pooling preparedStatements In-Reply-To: Message-ID: <20021231073904.F74213-100000@icarus.apache.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I don't see any problems with the sample code you provided. Based upon the "connection is closed" message, I'm guessing the problem lies in the way you're interacting with the JDBC classes. Just to rule out the obvious, you're not trying to use a PreparedStatement after the Connection has been closed, are you? Another possiblity is that you've somehow returned a connection to the pool more than once, and now two clients are holding onto it (and one closes it out from under the other). I think there are programatic checks that prevent that in the recent DBCP builds, but I'm not sure off hand how recently that was added (i.e., it may have been after the 1.0 release). On Fri, 27 Dec 2002 sergioboni@bb.com.br wrote: > Hi, > > I am using the dbcp package to pool my connections in our intranet. > It works very, very well with regular statements but i can't do it work > with preparedStatements. > Below is the method that i use. When i try to get a prepStatement i recei= ve > this: > > "Connection is closed". > > Where is the mistake? > > Thanks, > > S=E9rgio Bonif=E1cio. > > public DataSource setupDataSource(DBAlias alias)throws Exception { > > GenericObjectPool connectionPool =3D new GenericObjectPool(null); > connectionPool.setMaxActive(alias.getMaxConexoesSimultaneas()); > connectionPool.setMaxIdle(alias.getMaxConexoesOciosas()); > > //classe para possibilitar o uso de preparedStatements pelo pool > StackKeyedObjectPoolFactory stmPoolFactory =3D new > StackKeyedObjectPoolFactory(); > > ConnectionFactory connectionFactory =3D > new DriverManagerConnectionFactory( > alias.getURIConexao(), > alias.getUser(), > alias.getSenha()); > > PoolableConnectionFactory poolableConnectionFactory =3D > new PoolableConnectionFactory( > connectionFactory, > connectionPool, > stmPoolFactory, > null, > false, > true); > > > //obtem o data source do objectPool > PoolingDataSource dataSource =3D new > PoolingDataSource(connectionPool); > > System.out.println("Pool "+alias.getNomeAlias()+" configurado:"); > System.out.println("maximo de conexoes ativas: "+ > alias.getMaxConexoesSimultaneas()); > System.out.println("maximo de conexoes ociosas: " > +alias.getMaxConexoesOciosas()); > > return dataSource; > > } > > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > >