You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use ConnectionPool - org.apache.tomcat.jdbc.pool.DataSource
My database is Oracle with 300 limit open cursor
And this code finish with ORA-01000 Exception
for ( int i = 0; i < 400; i++ )
try(Connection con = AbsObject.getOpenedConnection() ) {
con.createQuery("insert into xxx ( id ) values ( 1 )" ).executeUpdate();
con.commit();
}
this code is correct : when I use con.commit(false)
for ( int i = 0; i < 400; i++ )
try(Connection con = AbsObject.getOpenedConnection() ) {
con.createQuery("insert into xxx ( id ) values ( 1 )" ).executeUpdate();
con.commit(false);
}
I see in source code problem in Connection.close()
Code getSql2o().getQuirks().closeStatement(statement) is never call if I use commit(true), because connectionIsClosed is true
if (!connectionIsClosed) {
for (Statement statement : statements) {
try {
getSql2o().getQuirks().closeStatement(statement);
} catch (Throwable e) {
logger.warn("Could not close statement.", e);
}
}
statements.clear();
I think that Connection.commit( boolean) for connection pool have to close preparedStatement.
And Connection.commit needs to be changed like this :
public Connection commit(boolean closeConnection){
try {
jdbcConnection.commit();
}
catch (SQLException e) {
throw new Sql2oException(e);
}
finally {
if(closeConnection) {
// ------------ close all prepared statement ----------- new code -----------
for (Statement statement : statements) {
try {
getSql2o().getQuirks().closeStatement(statement);
} catch (Throwable e) {
logger.warn("Could not close statement.", e);
}
}
statements.clear();
// -------------------------------------------------------------- end new code -------
this.closeJdbcConnection();
}
}
return this;
}
The text was updated successfully, but these errors were encountered:
I use ConnectionPool - org.apache.tomcat.jdbc.pool.DataSource
My database is Oracle with 300 limit open cursor
And this code finish with ORA-01000 Exception
for ( int i = 0; i < 400; i++ )
try(Connection con = AbsObject.getOpenedConnection() ) {
con.createQuery("insert into xxx ( id ) values ( 1 )" ).executeUpdate();
con.commit();
}
this code is correct : when I use con.commit(false)
for ( int i = 0; i < 400; i++ )
try(Connection con = AbsObject.getOpenedConnection() ) {
con.createQuery("insert into xxx ( id ) values ( 1 )" ).executeUpdate();
con.commit(false);
}
I see in source code problem in Connection.close()
Code getSql2o().getQuirks().closeStatement(statement) is never call if I use commit(true), because connectionIsClosed is true
I think that Connection.commit( boolean) for connection pool have to close preparedStatement.
And Connection.commit needs to be changed like this :
The text was updated successfully, but these errors were encountered: