use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest in project ignite by apache.
the class JdbcThinConnection method executeBatch.
/**
* @param lastBatch Whether open data streamers must be flushed and closed after this batch.
* @throws SQLException if failed.
*/
private void executeBatch(boolean lastBatch) throws SQLException {
JdbcBatchExecuteResult res = sendRequest(new JdbcBatchExecuteRequest(schema, streamBatch, lastBatch));
streamBatch = null;
lastStreamQry = null;
if (res.errorCode() != ClientListenerResponse.STATUS_SUCCESS) {
throw new BatchUpdateException(res.errorMessage(), IgniteQueryErrorCode.codeToSqlState(res.errorCode()), res.errorCode(), res.updateCounts());
}
}
use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest in project ignite by apache.
the class JdbcThinStatement method executeBatch.
/**
* {@inheritDoc}
*/
@Override
public int[] executeBatch() throws SQLException {
ensureNotClosed();
closeResults();
checkStatementBatchEmpty();
if (conn.isStream()) {
int[] res = new int[batchSize];
batchSize = 0;
return res;
}
if (F.isEmpty(batch))
return new int[0];
JdbcBatchExecuteRequest req = new JdbcBatchExecuteRequest(conn.getSchema(), batch, conn.getAutoCommit(), false);
try {
JdbcBatchExecuteResult res = conn.sendRequest(req, this, null).response();
if (res.errorCode() != ClientListenerResponse.STATUS_SUCCESS) {
throw new BatchUpdateException(res.errorMessage(), IgniteQueryErrorCode.codeToSqlState(res.errorCode()), res.errorCode(), res.updateCounts());
}
return res.updateCounts();
} finally {
batchSize = 0;
batch = null;
}
}
use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest in project ignite by apache.
the class JdbcThinTcpIo method guessCapacity.
/**
* Try to guess request capacity.
*
* @param req Request.
* @return Expected capacity.
*/
private static int guessCapacity(JdbcRequest req) {
int cap;
if (req instanceof JdbcBatchExecuteRequest) {
List<JdbcQuery> qrys = ((JdbcBatchExecuteRequest) req).queries();
int cnt = !F.isEmpty(qrys) ? Math.min(MAX_BATCH_QRY_CNT, qrys.size()) : 0;
// One additional byte for autocommit and last batch flags.
cap = cnt * DYNAMIC_SIZE_MSG_CAP + 2;
} else if (req instanceof JdbcQueryCloseRequest)
cap = QUERY_CLOSE_MSG_SIZE;
else if (req instanceof JdbcQueryMetadataRequest)
cap = QUERY_META_MSG_SIZE;
else if (req instanceof JdbcQueryFetchRequest)
cap = QUERY_FETCH_MSG_SIZE;
else
cap = DYNAMIC_SIZE_MSG_CAP;
return cap;
}
Aggregations