use of org.h2.command.CommandInterface in project h2database by h2database.
the class SessionWithState method readSessionState.
/**
* Read the session state if necessary.
*/
public void readSessionState() {
if (!sessionStateChanged || sessionStateUpdating) {
return;
}
sessionStateChanged = false;
sessionState = New.arrayList();
CommandInterface ci = prepareCommand("SELECT * FROM INFORMATION_SCHEMA.SESSION_STATE", Integer.MAX_VALUE);
ResultInterface result = ci.executeQuery(0, false);
while (result.next()) {
Value[] row = result.currentRow();
sessionState.add(row[1].getString());
}
}
use of org.h2.command.CommandInterface in project h2database by h2database.
the class JdbcConnection method setSavepoint.
/**
* Creates a new named savepoint.
*
* @param name the savepoint name
* @return the new savepoint
*/
@Override
public Savepoint setSavepoint(String name) throws SQLException {
try {
int id = getNextId(TraceObject.SAVEPOINT);
if (isDebugEnabled()) {
debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint(" + quote(name) + ")");
}
checkClosed();
CommandInterface set = prepareCommand("SAVEPOINT " + JdbcSavepoint.getName(name, 0), Integer.MAX_VALUE);
set.executeUpdate(false);
return new JdbcSavepoint(this, 0, name, trace, id);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.CommandInterface 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();
}
}
use of org.h2.command.CommandInterface in project h2database by h2database.
the class JdbcStatement method cancel.
/**
* Cancels a currently running statement.
* This method must be called from within another
* thread than the execute method.
* Operations on large objects are not interrupted,
* only operations that process many rows.
*
* @throws SQLException if this object is closed
*/
@Override
public void cancel() throws SQLException {
try {
debugCodeCall("cancel");
checkClosed();
// executingCommand can be reset by another thread
CommandInterface c = executingCommand;
try {
if (c != null) {
c.cancel();
cancelled = true;
}
} finally {
setExecutingStatement(null);
}
} catch (Exception e) {
throw logAndConvert(e);
}
}
Aggregations