[jira] [Created] (DBCP-366) Getting Exception when trying to get the PrepareStatement from Connection From DBCP Pool

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (DBCP-366) Getting Exception when trying to get the PrepareStatement from Connection From DBCP Pool

ASF GitHub Bot (Jira)
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


Using :commons-dbcp-1.2.2.jar version with Tomcat version 6.0.29

Geting the following exception when trying to get the java.sql.PrepareStatement using a Connection from DBCP Pool.


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)


This is the configuration we are using for creating Connection Pool from DBCP


----------------------------------------------------------------------------------------------
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;
}

----------------------------------------------------------------------------------------------------------------

The following code is used to  get the Connection is

---------------------------------------------------------------------------------------------------------------
public java.sql.Connection getConnection(poolName){
Connection con = DriverManager.getConnection("jdbc:apache:commons:dbcp:"+poolName);
return con;
}

----------------------------------------------------------------------------------------------------------------
The following code is used to release the connection

public void release(Connection conn) throws DBException {
                try {
                conn.close();
                } catch (Exception e) {
                        throw new Exception(e.getMessage(), e);
                }
}

-----------------------------------------------------------------------------------------------------------------

Can you let us know what might be the exact reason for the following exception

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira