Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9357610119 for ; Sat, 31 May 2014 04:38:43 +0000 (UTC) Received: (qmail 37081 invoked by uid 500); 31 May 2014 04:12:03 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 36961 invoked by uid 500); 31 May 2014 04:12:02 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 36823 invoked by uid 99); 31 May 2014 04:12:02 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 May 2014 04:12:02 +0000 Date: Sat, 31 May 2014 04:12:02 +0000 (UTC) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (DBCP-366) Getting Exception when trying to get the PrepareStatement from Connection From DBCP Pool MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DBCP-366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Phil Steitz closed DBCP-366. ---------------------------- > Getting Exception when trying to get the PrepareStatement from Connection From DBCP Pool > ---------------------------------------------------------------------------------------- > > Key: DBCP-366 > URL: https://issues.apache.org/jira/browse/DBCP-366 > Project: Commons Dbcp > Issue Type: Bug > Affects Versions: 1.2.2 > Environment: Linux machine > Reporter: saroj kumar balusu > Original Estimate: 24h > Remaining Estimate: 24h > > Using commons-dbcp-1.2.2.jar version with Tomcat version 6.0.29. > Getting the following exception when trying to get the java.sql.PrepareStatement using a Connection from DBCP Pool: > {noformat} > java.sql.SQLException: Connection is closed. > at org.apache.commons.dbcp.PoolingDriver$PoolGuardConnectionWrapper.checkOpen(PoolingDriver.java:263) > at org.apache.commons.dbcp.PoolingDriver$PoolGuardConnectionWrapper.prepareStatement(PoolingDriver.java:366) > {noformat} > This is the configuration we are using for creating Connection Pool from DBCP: > {code:java} > public static void setupDriver(String connectURI, String userName, > String dbPassword, String maxActive, String minIdle, > String maxWait, String poolName) throws Exception { > GenericObjectPool.Config config = new GenericObjectPool.Config(); > config.maxActive = Integer.parseInt(maxActive); > config.minIdle = Integer.parseInt(minIdle); > config.maxWait = Integer.parseInt(maxWait); > config.whenExhaustedAction = 2; > config.minEvictableIdleTimeMillis = 1800000; > config.timeBetweenEvictionRunsMillis = 1800000; > config.numTestsPerEvictionRun = 3; > config.testOnBorrow = true; > config.testOnReturn = true; > config.testWhileIdle = true; > ObjectPool connectionPool = new GenericObjectPool(null, config); > ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( > connectURI, userName, dbPassword); > PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( > connectionFactory, connectionPool, null, null, false, true); > poolableConnectionFactory.setValidationQuery("select 1 from dual"); > driver = new PoolingDriver(); > driver.registerPool(poolName, connectionPool); > driver.setAccessToUnderlyingConnectionAllowed(true); > // PoolingDataSource dataSource = new PoolingDataSource(connectionPool); > // return dataSource; > } > {code} > The following code is used to get the Connection: > {code:java} > public java.sql.Connection getConnection(poolName) { > Connection con = DriverManager.getConnection("jdbc:apache:commons:dbcp:"+poolName); > return con; > } > {code} > The following code is used to release the connection: > {code:java} > public void release(Connection conn) throws DBException { > try { > conn.close(); > } catch (Exception e) { > throw new Exception(e.getMessage(), e); > } > } > {code} > Can you let us know what might be the exact reason for the following exception? -- This message was sent by Atlassian JIRA (v6.2#6252)