5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-03 22:34:30 +08:00

SQOOP-808: SQLExceptions From Batched Exports Aren't Very Helpful

(Nick White via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2013-01-06 02:30:15 -08:00
parent 8029ed0cfc
commit 7573450e18

View File

@ -19,10 +19,12 @@
package org.apache.sqoop.mapreduce;
import java.io.IOException;
import java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.SynchronousQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.mapreduce.JobContext;
@ -30,6 +32,7 @@
import org.apache.hadoop.mapreduce.OutputFormat;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.util.StringUtils;
import com.cloudera.sqoop.lib.SqoopRecord;
/**
@ -241,6 +244,20 @@ public void run() {
this.conn.commit();
this.curNumStatements = 0;
}
} catch (BatchUpdateException batchE) {
if (batchE.getNextException() != null) {
// if a statement in a batch causes an SQLException
// the database can either set it as the cause of
// the BatchUpdateException, or set it as the 'next'
// field of the BatchUpdateException (e.g. HSQLDB 1.8
// does the former and Postgres 8.4 does the latter).
// We'll check for this SQLException in both places,
// and use the 'next' one in preference.
setLastError(batchE.getNextException());
} else {
// same as SQLException block
setLastError(batchE);
}
} catch (SQLException sqlE) {
setLastError(sqlE);
} finally {