public void releaseStatement(Statement statement, String sqlString, DatabaseCall call, AbstractSession session) throws SQLException {
if (call.usesBinding(session) && call.shouldCacheStatement(session)) {
synchronized (getStatementCache()) {
PreparedStatement preparedStatement = (PreparedStatement)statement;
if (!getStatementCache().containsKey(sqlString)) {// May already be there by other thread.
preparedStatement.clearParameters();
// Bug 5709179 - reset statement settings on cached statements (dminsky) - inclusion of reset
resetStatementFromCall(preparedStatement, call);
if (getStatementCache().size() > getPlatform().getStatementCacheSize()) {
// Currently one is removed at random...
PreparedStatement removedStatement = (PreparedStatement)getStatementCache().remove(getStatementCache().keys().nextElement());