use of org.apache.gobblin.converter.jdbc.JdbcEntryData in project incubator-gobblin by apache.
the class TeradataBufferedInserter method insertBatch.
@Override
protected boolean insertBatch(PreparedStatement pstmt) throws SQLException {
for (JdbcEntryData pendingEntry : TeradataBufferedInserter.this.pendingInserts) {
int i = 1;
for (JdbcEntryDatum datum : pendingEntry) {
Object value = datum.getVal();
if (value != null) {
pstmt.setObject(i, value);
} else {
// Column type is needed for null value insertion
pstmt.setNull(i, columnPosSqlTypes.get(i));
}
i++;
}
pstmt.addBatch();
pstmt.clearParameters();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Executing SQL " + pstmt);
}
int[] execStatus = pstmt.executeBatch();
// Check status explicitly if driver continues batch insertion upon failure
for (int status : execStatus) {
if (status == Statement.EXECUTE_FAILED) {
throw new BatchUpdateException("Batch insert failed.", execStatus);
}
}
return true;
}
Aggregations