if (connection != null) {
if ((connection != null) && closeConnWhenDone) {
    private void cleanup(Connection connection, Statement statement, ResultSet result) {        if (result != null) {            try {                result.close();            } catch (SQLException ex) {                log.error("Error closing resultset", ex);            }        }        if (statement != null) {            try {                statement.close();            } catch (SQLException ex) {                log.error("Error closing statement", ex);            }        }        if (connection != null) {            try {                connection.close();            } catch (SQLException ex) {                log.error("Error closing connection", ex);            }        }    }