use of org.apache.ignite.client.proto.query.event.QueryExecuteRequest in project ignite-3 by apache.
the class JdbcStatement method execute0.
/**
* Execute the query with given parameters.
*
* @param sql Sql query.
* @param args Query parameters.
* @throws SQLException Onj error.
*/
protected void execute0(JdbcStatementType stmtType, String sql, List<Object> args) throws SQLException {
ensureNotClosed();
closeResults();
if (sql == null || sql.isEmpty()) {
throw new SQLException("SQL query is empty.");
}
QueryExecuteRequest req = new QueryExecuteRequest(stmtType, schema, pageSize, maxRows, sql, args == null ? ArrayUtils.OBJECT_EMPTY_ARRAY : args.toArray());
QueryExecuteResult res = conn.handler().queryAsync(req).join();
if (!res.hasResults()) {
throw IgniteQueryErrorCode.createJdbcSqlException(res.err(), res.status());
}
for (QuerySingleResult jdbcRes : res.results()) {
if (!jdbcRes.hasResults()) {
throw IgniteQueryErrorCode.createJdbcSqlException(jdbcRes.err(), jdbcRes.status());
}
}
resSets = new ArrayList<>(res.results().size());
for (QuerySingleResult jdbcRes : res.results()) {
resSets.add(new JdbcResultSet(this, jdbcRes.cursorId(), pageSize, jdbcRes.last(), jdbcRes.items(), jdbcRes.isQuery(), false, jdbcRes.updateCount(), closeOnCompletion, conn.handler()));
}
assert !resSets.isEmpty() : "At least one results set is expected";
}
Aggregations