Search in sources :

Example 1 with JdbcBatchExecuteResult

use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult 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());
    }
}
Also used : JdbcBatchExecuteRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest) JdbcBatchExecuteResult(org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult) BatchUpdateException(java.sql.BatchUpdateException)

Example 2 with JdbcBatchExecuteResult

use of org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult 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;
    }
}
Also used : JdbcBatchExecuteRequest(org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest) JdbcBatchExecuteResult(org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult) BatchUpdateException(java.sql.BatchUpdateException)

Aggregations

BatchUpdateException (java.sql.BatchUpdateException)2 JdbcBatchExecuteRequest (org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteRequest)2 JdbcBatchExecuteResult (org.apache.ignite.internal.processors.odbc.jdbc.JdbcBatchExecuteResult)2