sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-808: SQLExceptions From Batched Exports Aren't Very Helpful
Date Sun, 06 Jan 2013 10:31:41 GMT
Updated Branches:
  refs/heads/trunk 8029ed0cf -> 7573450e1


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

(Nick White via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/7573450e
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/7573450e
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/7573450e

Branch: refs/heads/trunk
Commit: 7573450e18a577a0c6c61b2eae40ff47aa17c572
Parents: 8029ed0
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Sun Jan 6 02:30:15 2013 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Sun Jan 6 02:30:15 2013 -0800

----------------------------------------------------------------------
 .../sqoop/mapreduce/AsyncSqlOutputFormat.java      |   17 +++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/7573450e/src/java/org/apache/sqoop/mapreduce/AsyncSqlOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/mapreduce/AsyncSqlOutputFormat.java b/src/java/org/apache/sqoop/mapreduce/AsyncSqlOutputFormat.java
index bb29bc2..ce11f84 100644
--- a/src/java/org/apache/sqoop/mapreduce/AsyncSqlOutputFormat.java
+++ b/src/java/org/apache/sqoop/mapreduce/AsyncSqlOutputFormat.java
@@ -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.OutputCommitter;
 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 abstract class AsyncSqlOutputFormat<K extends SqoopRecord,
V>
               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 {


Mime
View raw message