commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (DBCP-366) Getting Exception when trying to get the PrepareStatement from Connection From DBCP Pool
Date Sat, 31 May 2014 04:12:02 GMT

     [ 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)

Mime
View raw message