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 4703 invoked by uid 98); 27 Dec 2002 22:02:55 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 4684 invoked from network); 27 Dec 2002 22:02:53 -0000 Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142) by nagoya.betaversion.org with SMTP; 27 Dec 2002 22:02:53 -0000 Received: (qmail 38896 invoked by uid 500); 27 Dec 2002 22:01:34 -0000 Received: (qmail 38889 invoked from network); 27 Dec 2002 22:01:33 -0000 Received: from unknown (HELO srdfmailer01.bb.com.br) (170.66.1.95) by daedalus.apache.org with SMTP; 27 Dec 2002 22:01:33 -0000 Received: from correio.bb.com.br (bbcorreio01.bancodobrasil.com.br [170.66.1.90]) by srdfmailer01.bb.com.br (8.11.1/8.11.1) with ESMTP id gBRM8RV15629; Fri, 27 Dec 2002 20:08:27 -0200 (EDT) Subject: How to Pooling preparedStatements To: commons-user@jakarta.apache.org Cc: sergioboni@uol.com.br X-Mailer: Lotus Notes Release 5.0.2c (Intl)8 Fevereiro 2000 Message-ID: From: sergioboni@bb.com.br Date: Fri, 27 Dec 2002 20:00:37 -0200 X-MIMETrack: Serialize by Router on bsbpma01/BANCO DO BRASIL(Release 5.0.8 SPRs JCHN4RQFHZ BSUN53DJBQ |November 7, 2002) at 27/12/2002 08:00:41 PM MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 wor= k with preparedStatements. Below is the method that i use. When i try to get a prepStatement i rec= eive 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; }=