use of org.h2.result.ResultWithGeneratedKeys in project h2database by h2database.
the class JdbcStatement method executeInternal.
private boolean executeInternal(String sql, Object generatedKeysRequest) throws SQLException {
int id = getNextId(TraceObject.RESULT_SET);
checkClosedForWrite();
try {
closeOldResultSet();
sql = JdbcConnection.translateSQL(sql, escapeProcessing);
CommandInterface command = conn.prepareCommand(sql, fetchSize);
boolean lazy = false;
boolean returnsResultSet;
synchronized (session) {
setExecutingStatement(command);
try {
if (command.isQuery()) {
returnsResultSet = true;
boolean scrollable = resultSetType != ResultSet.TYPE_FORWARD_ONLY;
boolean updatable = resultSetConcurrency == ResultSet.CONCUR_UPDATABLE;
ResultInterface result = command.executeQuery(maxRows, scrollable);
lazy = result.isLazy();
resultSet = new JdbcResultSet(conn, this, command, result, id, closedByResultSet, scrollable, updatable);
} else {
returnsResultSet = false;
ResultWithGeneratedKeys result = command.executeUpdate(conn.scopeGeneratedKeys() ? false : generatedKeysRequest);
updateCount = result.getUpdateCount();
ResultInterface gk = result.getGeneratedKeys();
if (gk != null) {
generatedKeys = new JdbcResultSet(conn, this, command, gk, id, false, true, false);
}
}
} finally {
if (!lazy) {
setExecutingStatement(null);
}
}
}
if (!lazy) {
command.close();
}
return returnsResultSet;
} finally {
afterWriting();
}
}
Aggregations