Re: [dbcp] No operations allowed after statement closed
On 5/27/15 3:10 PM, Ajay kumar Gour wrote: Hi there, One of the application I am working on is using commons-dbcp-1.2.2.jar. Below is my data source configuration – Resource id=myDS type=javax.sql.DataSource JdbcDriver com.mysql.jdbc.Driver JdbcUrl jdbc:mysql://localhost:3306/test?relaxAutoCommit=true UserName root Password JtaManaged true MaxWait 0 PoolPreparedStatements true MaxOpenPreparedStatements 20 MaxActive 5 MinEvictableIdleTime 5 minutes TimeBetweenEvictionRuns 12 millisecond NumTestsPerEvictionRun 5 TestWhileIdle false TestOnBorrow true ValidationQuery Select 1 from dual /Resource Problem is, ever since I enabled eviction (also reduced MaxOpenPreparedStatement value), I am continuously getting following error Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed. at sun.reflect.GeneratedConstructorAccessor421.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:463) at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3819) at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:3849) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.hibernate.type.LongType.set(LongType.java:42) I have tried updating dbcp-1.2.2 to dbcp-1.4, but same error. Could somebody please help me understand why is this happening? Is there a bug in DBCP’s statement pooling? It seems that statements are getting closed but they are not removed from the pool. If you can separate the evictor activation change from the maxOpenPreparedStatement change that will help narrow down the problem. One possibility is that your code is closing statements, but holding references to them and then reusing them. Check that that is not happening. What could be going on is with large maxOpenPreparedStatement, code closes a statement, but holds a reference to it. Closing it returns it to the statement pool on the connection, but does not close the physical connection. When you impose a maxOpenPreparedStatement limit, some of those returning statments are going to get closed on return to the pool. If your client code is holding references to them and trying to do things with them, the driver exceptions below would make sense. Phil Thanks, -Ajay - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [dbcp] No operations allowed after statement closed
Please try version 2.1. Gary On Wed, May 27, 2015 at 3:10 PM, Ajay kumar Gour ajay.g...@gmail.com wrote: Hi there, One of the application I am working on is using commons-dbcp-1.2.2.jar. Below is my data source configuration – Resource id=myDS type=javax.sql.DataSource JdbcDriver com.mysql.jdbc.Driver JdbcUrl jdbc:mysql://localhost:3306/test?relaxAutoCommit=true UserName root Password JtaManaged true MaxWait 0 PoolPreparedStatements true MaxOpenPreparedStatements 20 MaxActive 5 MinEvictableIdleTime 5 minutes TimeBetweenEvictionRuns 12 millisecond NumTestsPerEvictionRun 5 TestWhileIdle false TestOnBorrow true ValidationQuery Select 1 from dual /Resource Problem is, ever since I enabled eviction (also reduced MaxOpenPreparedStatement value), I am continuously getting following error Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed. at sun.reflect.GeneratedConstructorAccessor421.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:463) at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3819) at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:3849) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.hibernate.type.LongType.set(LongType.java:42) I have tried updating dbcp-1.2.2 to dbcp-1.4, but same error. Could somebody please help me understand why is this happening? Is there a bug in DBCP’s statement pooling? It seems that statements are getting closed but they are not removed from the pool. Thanks, -Ajay -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition http://www.manning.com/bauer3/ JUnit in Action, Second Edition http://www.manning.com/tahchiev/ Spring Batch in Action http://www.manning.com/templier/ Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
[dbcp] No operations allowed after statement closed
Hi there, One of the application I am working on is using commons-dbcp-1.2.2.jar. Below is my data source configuration – Resource id=myDS type=javax.sql.DataSource JdbcDriver com.mysql.jdbc.Driver JdbcUrl jdbc:mysql://localhost:3306/test?relaxAutoCommit=true UserName root Password JtaManaged true MaxWait 0 PoolPreparedStatements true MaxOpenPreparedStatements 20 MaxActive 5 MinEvictableIdleTime 5 minutes TimeBetweenEvictionRuns 12 millisecond NumTestsPerEvictionRun 5 TestWhileIdle false TestOnBorrow true ValidationQuery Select 1 from dual /Resource Problem is, ever since I enabled eviction (also reduced MaxOpenPreparedStatement value), I am continuously getting following error Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed. at sun.reflect.GeneratedConstructorAccessor421.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:463) at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3819) at com.mysql.jdbc.PreparedStatement.setLong(PreparedStatement.java:3849) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.apache.commons.dbcp.DelegatingPreparedStatement.setLong(DelegatingPreparedStatement.java:123) at org.hibernate.type.LongType.set(LongType.java:42) I have tried updating dbcp-1.2.2 to dbcp-1.4, but same error. Could somebody please help me understand why is this happening? Is there a bug in DBCP’s statement pooling? It seems that statements are getting closed but they are not removed from the pool. Thanks, -Ajay