use of org.h2.engine.Session in project ignite by apache.
the class IgniteH2Indexing method executeSqlQuery.
/**
* Executes sql query statement.
*
* @param conn Connection,.
* @param stmt Statement.
* @param timeoutMillis Query timeout.
* @param cancel Query cancel.
* @return Result.
* @throws IgniteCheckedException If failed.
*/
private ResultSet executeSqlQuery(final Connection conn, final PreparedStatement stmt, int timeoutMillis, @Nullable GridQueryCancel cancel) throws IgniteCheckedException {
final MapQueryLazyWorker lazyWorker = MapQueryLazyWorker.currentWorker();
if (cancel != null) {
cancel.set(new Runnable() {
@Override
public void run() {
if (lazyWorker != null) {
lazyWorker.submit(new Runnable() {
@Override
public void run() {
cancelStatement(stmt);
}
});
} else
cancelStatement(stmt);
}
});
}
Session ses = H2Utils.session(conn);
if (timeoutMillis > 0)
ses.setQueryTimeout(timeoutMillis);
if (lazyWorker != null)
ses.setLazyQueryExecution(true);
try {
return stmt.executeQuery();
} catch (SQLException e) {
// Throw special exception.
if (e.getErrorCode() == ErrorCode.STATEMENT_WAS_CANCELED)
throw new QueryCancelledException();
throw new IgniteCheckedException("Failed to execute SQL query. " + e.getMessage(), e);
} finally {
if (timeoutMillis > 0)
ses.setQueryTimeout(0);
if (lazyWorker != null)
ses.setLazyQueryExecution(false);
}
}
use of org.h2.engine.Session in project ignite by apache.
the class H2PkHashIndex method getRowCount.
/**
* {@inheritDoc}
*/
@Override
public long getRowCount(Session ses) {
Cursor cursor = find(ses, null, null);
long res = 0;
while (cursor.next()) res++;
return res;
}
Aggregations