From c913f77f284cb27ce5aa43fd433b59a52d3032b3 Mon Sep 17 00:00:00 2001 From: Hari Shreedharan Date: Mon, 3 Feb 2014 16:08:47 -0800 Subject: [PATCH] SQOOP-1279. Sqoop connection resiliency option breaks older Mysql versions that don't have JDBC 4 methods (Venkat Ranganathan via Hari Shreedharan) --- .../org/apache/sqoop/mapreduce/db/DBRecordReader.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/sqoop/mapreduce/db/DBRecordReader.java b/src/java/org/apache/sqoop/mapreduce/db/DBRecordReader.java index e33e4271..a78eb061 100644 --- a/src/java/org/apache/sqoop/mapreduce/db/DBRecordReader.java +++ b/src/java/org/apache/sqoop/mapreduce/db/DBRecordReader.java @@ -154,13 +154,15 @@ protected String getSelectQuery() { } @Override - /** {@inheritDoc} */ public void close() throws IOException { try { if (null != results) { results.close(); } - if (null != statement && !statement.isClosed()) { + // Statement.isClosed() is only available from JDBC 4 + // Some older drivers (like mysql 5.0.x and earlier fail with + // the check for statement.isClosed() + if (null != statement) { statement.close(); } if (null != connection && !connection.isClosed()) { @@ -178,13 +180,11 @@ public void initialize(InputSplit inputSplit, TaskAttemptContext context) } @Override - /** {@inheritDoc} */ public LongWritable getCurrentKey() { return key; } @Override - /** {@inheritDoc} */ public T getCurrentValue() { return value; } @@ -216,13 +216,11 @@ public boolean next(LongWritable k, T v) throws IOException { } @Override - /** {@inheritDoc} */ public float getProgress() throws IOException { return pos / (float)split.getLength(); } @Override - /** {@inheritDoc} */ public boolean nextKeyValue() throws IOException { try { if (key == null) {