You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by bl...@apache.org on 2012/10/05 22:23:23 UTC

git commit: SQOOP-620: Introduce name to connection and job objects (Jarek Cecho)

Updated Branches:
  refs/heads/sqoop2 202ae0630 -> f1893ab9b


SQOOP-620: Introduce name to connection and job objects
(Jarek Cecho)


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

Branch: refs/heads/sqoop2
Commit: f1893ab9bb143598c79ac51211bc5153b99c0db4
Parents: 202ae06
Author: Bilung Lee <bl...@apache.org>
Authored: Fri Oct 5 13:22:32 2012 -0700
Committer: Bilung Lee <bl...@apache.org>
Committed: Fri Oct 5 13:22:32 2012 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |   30 ++++
 .../org/apache/sqoop/client/core/Environment.java  |   14 ++-
 .../client/shell/CloneConnectionFunction.java      |   17 +--
 .../sqoop/client/shell/CloneJobFunction.java       |   16 +--
 .../client/shell/CreateConnectionFunction.java     |   17 +--
 .../sqoop/client/shell/CreateJobFunction.java      |   16 +--
 .../client/shell/UpdateConnectionFunction.java     |   17 +--
 .../sqoop/client/shell/UpdateJobFunction.java      |   16 +--
 .../org/apache/sqoop/client/utils/FormFiller.java  |  111 ++++++++++++++-
 .../src/main/resources/client-resource.properties  |   23 +++
 .../apache/sqoop/connector/ConnectorManager.java   |    1 +
 .../repository/derby/DerbyRepositoryHandler.java   |   45 ++++---
 .../sqoop/repository/derby/DerbySchemaQuery.java   |    8 +
 .../repository/derby/TestConnectionHandling.java   |    4 +
 .../sqoop/repository/derby/TestJobHandling.java    |    4 +
 15 files changed, 246 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/core/Constants.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Constants.java b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
new file mode 100644
index 0000000..47c0547
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.client.core;
+
+/**
+ *
+ */
+public class Constants {
+
+  public static final String RESOURCE_NAME = "client-resource";
+
+  private Constants() {
+    // Instantiation is prohibited
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/core/Environment.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Environment.java b/client/src/main/java/org/apache/sqoop/client/core/Environment.java
index b496d43..2afd0f7 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/Environment.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/Environment.java
@@ -17,6 +17,9 @@
  */
 package org.apache.sqoop.client.core;
 
+import java.util.Locale;
+import java.util.ResourceBundle;
+
 public class Environment
 {
   private Environment() {
@@ -31,10 +34,15 @@ public class Environment
   private static String PORT_DEFAULT = "8080";
   private static String WEBAPP_DEFAULT = "sqoop";
 
+  private static ResourceBundle resourceBundle;
+
   static {
     serverHost = HOST_DEFAULT;
     serverPort = PORT_DEFAULT;
     serverWebapp = WEBAPP_DEFAULT;
+
+    resourceBundle =
+      ResourceBundle.getBundle(Constants.RESOURCE_NAME, Locale.getDefault());
   }
 
   public static void setServerHost(String host) {
@@ -64,4 +72,8 @@ public class Environment
   public static String getServerUrl() {
     return "http://" + serverHost + ":" + serverPort + "/" + serverWebapp + "/";
   }
-}
\ No newline at end of file
+
+  public static ResourceBundle getResourceBundle() {
+    return resourceBundle;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java
index c5fd992..eac23c6 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/CloneConnectionFunction.java
@@ -97,21 +97,14 @@ public class CloneConnectionFunction extends SqoopFunction {
     io.out.println("Please update connection metadata:");
 
     do {
+      // Print error introduction if needed
       if( !status.canProceed() ) {
-        io.out.println();
-        io.out.println("@|red There are issues with entered data, please"
-          + " revise your input:|@");
+        errorIntroduction(io);
       }
 
-      // Query connector forms
-      if(!fillForms(io, connection.getConnectorPart().getForms(),
-                    reader, connectorBundle)) {
-        return;
-      }
-
-      // Query framework forms
-      if(!fillForms(io, connection.getFrameworkPart().getForms(),
-                    reader, frameworkBundle)) {
+      // Fill in data from user
+      if(!fillConnection(io, reader, connection,
+                         connectorBundle, frameworkBundle)) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java
index 94df945..536b7f3 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/CloneJobFunction.java
@@ -96,21 +96,13 @@ public class CloneJobFunction extends SqoopFunction {
     io.out.println("Please update job metadata:");
 
     do {
+      // Print error introduction if needed
       if( !status.canProceed() ) {
-        io.out.println();
-        io.out.println("@|red There are issues with entered data, please"
-          + " revise your input:|@");
+        errorIntroduction(io);
       }
 
-      // Query connector forms
-      if(!fillForms(io, job.getConnectorPart().getForms(),
-        reader, connectorBundle)) {
-        return;
-      }
-
-      // Query framework forms
-      if(!fillForms(io, job.getFrameworkPart().getForms(),
-        reader, frameworkBundle)) {
+      // Fill in data from user
+      if(!fillJob(io, reader, job, connectorBundle, frameworkBundle)) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
index 4e5c916..f35ba5b 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/CreateConnectionFunction.java
@@ -104,21 +104,14 @@ public class CreateConnectionFunction extends SqoopFunction {
       + " object");
 
     do {
+      // Print error introduction if needed
       if( !status.canProceed() ) {
-        io.out.println();
-        io.out.println("@|red There are issues with entered data, please"
-          + " revise your input:|@");
+        errorIntroduction(io);
       }
 
-      // Query connector forms
-      if(!fillForms(io, connection.getConnectorPart().getForms(),
-                    reader, connectorBundle)) {
-        return;
-      }
-
-      // Query framework forms
-      if(!fillForms(io, connection.getFrameworkPart().getForms(),
-                    reader, frameworkBundle)) {
+      // Fill in data from user
+      if(!fillConnection(io, reader, connection,
+                         connectorBundle, frameworkBundle)) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
index 0db93bf..41f43a3 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/CreateJobFunction.java
@@ -130,21 +130,13 @@ public class CreateJobFunction extends  SqoopFunction {
       + " object");
 
     do {
+      // Print error introduction if needed
       if( !status.canProceed() ) {
-        io.out.println();
-        io.out.println("@|red There are issues with entered data, please"
-          + " revise your input:|@");
+        errorIntroduction(io);
       }
 
-      // Query connector forms
-      if(!fillForms(io, job.getConnectorPart().getForms(),
-                    reader, connectorBundle)) {
-        return;
-      }
-
-      // Query framework forms
-      if(!fillForms(io, job.getFrameworkPart().getForms(),
-                    reader, frameworkBundle)) {
+      // Fill in data from user
+      if(!fillJob(io, reader, job, connectorBundle, frameworkBundle)) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
index 1d64296..64604f1 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
@@ -92,21 +92,14 @@ public class UpdateConnectionFunction extends SqoopFunction {
     io.out.println("Please update connection metadata:");
 
     do {
+      // Print error introduction if needed
       if( !status.canProceed() ) {
-        io.out.println();
-        io.out.println("@|red There are issues with entered data, please"
-          + " revise your input:|@");
+        errorIntroduction(io);
       }
 
-      // Query connector forms
-      if(!fillForms(io, connection.getConnectorPart().getForms(),
-                    reader, connectorBundle)) {
-        return;
-      }
-
-      // Query framework forms
-      if(!fillForms(io, connection.getFrameworkPart().getForms(),
-                    reader, frameworkBundle)) {
+      // Fill in data from user
+      if(!fillConnection(io, reader, connection,
+                         connectorBundle, frameworkBundle)) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
index 9924cf9..ee387fd 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
@@ -92,21 +92,13 @@ public class UpdateJobFunction extends SqoopFunction {
     io.out.println("Please update job metadata:");
 
     do {
+      // Print error introduction if needed
       if( !status.canProceed() ) {
-        io.out.println();
-        io.out.println("@|red There are issues with entered data, please"
-          + " revise your input:|@");
+        errorIntroduction(io);
       }
 
-      // Query connector forms
-      if(!fillForms(io, job.getConnectorPart().getForms(),
-        reader, connectorBundle)) {
-        return;
-      }
-
-      // Query framework forms
-      if(!fillForms(io, job.getFrameworkPart().getForms(),
-        reader, frameworkBundle)) {
+      // Fill in data from user
+      if(!fillJob(io, reader, job, connectorBundle, frameworkBundle)) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java b/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
index 2404587..4e58a34 100644
--- a/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
+++ b/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
@@ -18,9 +18,12 @@
 package org.apache.sqoop.client.utils;
 
 import jline.ConsoleReader;
+import org.apache.sqoop.client.core.Environment;
+import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MStringInput;
 import org.codehaus.groovy.tools.shell.IO;
 
@@ -29,10 +32,97 @@ import java.util.List;
 import java.util.ResourceBundle;
 
 /**
- *
+ * Convenient methods for retrieving user input.
  */
 public class FormFiller {
 
+  /**
+   * Internal input that will be reused for loading names for connection and
+   * job objects.
+   */
+  private static MStringInput nameInput =
+    new MStringInput("object-name", false, (short)25);
+
+  /**
+   * Fill job object based on user input.
+   *
+   * @param io Shell's io object
+   * @param reader Associated console reader object
+   * @param job Job that user is suppose to fill in
+   * @param connectorBundle Connector resource bundle
+   * @param frameworkBundle Framework resource bundle
+   * @return True if we filled all inputs, false if user has stopped processing
+   * @throws IOException
+   */
+  public static boolean fillJob(IO io,
+                                ConsoleReader reader,
+                                MJob job,
+                                ResourceBundle connectorBundle,
+                                ResourceBundle frameworkBundle)
+                                throws IOException {
+
+    job.setName(getName(io, reader, job.getName()));
+
+    // Fill in data from user
+     return fillForms(io,
+                      reader,
+                      job.getConnectorPart().getForms(),
+                      connectorBundle,
+                      job.getFrameworkPart().getForms(),
+                      frameworkBundle);
+  }
+
+  /**
+   * Fill connection object based on user input.
+   *
+   * @param io Shell's io object
+   * @param reader Associated console reader object
+   * @param connection Connection that user is suppose to fill in
+   * @param connectorBundle Connector resource bundle
+   * @param frameworkBundle Framework resouce bundle
+   * @return True if we filled all inputs, false if user has stopped processing
+   * @throws IOException
+   */
+  public static boolean fillConnection(IO io,
+                                       ConsoleReader reader,
+                                       MConnection connection,
+                                       ResourceBundle connectorBundle,
+                                       ResourceBundle frameworkBundle)
+                                       throws IOException {
+
+    connection.setName(getName(io, reader, connection.getName()));
+
+    // Fill in data from user
+     return fillForms(io,
+                      reader,
+                      connection.getConnectorPart().getForms(),
+                      connectorBundle,
+                      connection.getFrameworkPart().getForms(),
+                      frameworkBundle);
+  }
+
+  public static boolean fillForms(IO io,
+                                  ConsoleReader reader,
+                                  List<MForm> connectorForms,
+                                  ResourceBundle connectorBundle,
+                                  List<MForm> frameworkForms,
+                                  ResourceBundle frameworkBundle
+                                  ) throws IOException {
+
+
+    // Query connector forms
+    if(!fillForms(io, connectorForms, reader, connectorBundle)) {
+      return false;
+    }
+
+    // Query framework forms
+    if(!fillForms(io, frameworkForms, reader, frameworkBundle)) {
+      return false;
+    }
+
+    return true;
+  }
+
   public static boolean fillForms(IO io,
                                   List<MForm> forms,
                                   ConsoleReader reader,
@@ -167,6 +257,19 @@ public class FormFiller {
     reader.flushConsole();
   }
 
+  public static String getName(IO io, ConsoleReader reader,
+                               String name) throws IOException {
+    if(name == null) {
+      nameInput.setEmpty();
+    } else {
+      nameInput.setValue(name);
+    }
+
+    fillInputString(io, nameInput, reader, Environment.getResourceBundle());
+
+    return nameInput.getValue();
+  }
+
   public static void errorMessage(IO io, String message) {
     io.out.println("Error message: @|red " + message + " |@");
   }
@@ -175,6 +278,12 @@ public class FormFiller {
     io.out.println("Warning message: @|yellow " + message + " |@");
   }
 
+  public static void errorIntroduction(IO io) {
+    io.out.println();
+    io.out.println("@|red There are issues with entered data, please"
+      + " revise your input:|@");
+  }
+
   private FormFiller() {
     // Do not instantiate
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/client/src/main/resources/client-resource.properties
----------------------------------------------------------------------
diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties
new file mode 100644
index 0000000..793ddc8
--- /dev/null
+++ b/client/src/main/resources/client-resource.properties
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Client Resources in default language (english)
+
+############################
+# Security Form
+#
+object-name-label = Name
+object-name-help = Non unique name of the entity to help you remember \
+                   it's purpose

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index ea368da..8dc3704 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -167,6 +167,7 @@ public class ConnectorManager {
           throw new SqoopException(ConnectorError.CONN_0010, connectorName);
         }
         nameMap.put(handler.getMetadata().getPersistenceId(), connectorName);
+        LOG.debug("Registered connector: " + handler.getMetadata());
       }
       rtx.commit();
     } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index ef3d804..4d7c3fc 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -446,18 +446,21 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler {
    */
   @Override
   public void updateConnection(MConnection connection, Connection conn) {
-    // We're not allowing updating values in SQ_CONNECTION (name, connector id)
-    // TODO(jarcec): Remove this limitation
-    // TODO(jarcec): check that connector and other values are not changed!
-
-    PreparedStatement stmt = null;
+    PreparedStatement deleteStmt = null;
+    PreparedStatement updateStmt = null;
     try {
       // Firstly remove old values
-      stmt = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
-      stmt.setLong(1, connection.getPersistenceId());
-      stmt.executeUpdate();
+      deleteStmt = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
+      deleteStmt.setLong(1, connection.getPersistenceId());
+      deleteStmt.executeUpdate();
 
-      // And reinsert new ones
+      // Update CONNECTION table
+      updateStmt = conn.prepareStatement(STMT_UPDATE_CONNECTION);
+      updateStmt.setString(1, connection.getName());
+      updateStmt.setLong(2, connection.getPersistenceId());
+      updateStmt.executeUpdate();
+
+      // And reinsert new values
       createInputValues(STMT_INSERT_CONNECTION_INPUT,
         connection.getPersistenceId(),
         connection.getConnectorPart().getForms(),
@@ -470,7 +473,7 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler {
     } catch (SQLException ex) {
       throw new SqoopException(DerbyRepoError.DERBYREPO_0021, ex);
     } finally {
-      closeStatements(stmt);
+      closeStatements(deleteStmt, updateStmt);
     }
   }
 
@@ -618,17 +621,21 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler {
    */
   @Override
   public void updateJob(MJob job, Connection conn) {
-    // We're not allowing updating values in SQ_JOB (name, type, connection)
-    // TODO(jarcec): Remove this limitation
-
-    PreparedStatement stmt = null;
+    PreparedStatement deleteStmt = null;
+    PreparedStatement updateStmt = null;
     try {
       // Firstly remove old values
-      stmt = conn.prepareStatement(STMT_DELETE_JOB_INPUT);
-      stmt.setLong(1, job.getPersistenceId());
-      stmt.executeUpdate();
+      deleteStmt = conn.prepareStatement(STMT_DELETE_JOB_INPUT);
+      deleteStmt.setLong(1, job.getPersistenceId());
+      deleteStmt.executeUpdate();
 
-      // And reinsert new ones
+      // Update job table
+      updateStmt = conn.prepareStatement(STMT_UPDATE_JOB);
+      updateStmt.setString(1, job.getName());
+      updateStmt.setLong(2, job.getPersistenceId());
+      updateStmt.executeUpdate();
+
+      // And reinsert new values
       createInputValues(STMT_INSERT_JOB_INPUT,
                         job.getPersistenceId(),
                         job.getConnectorPart().getForms(),
@@ -641,7 +648,7 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler {
     } catch (SQLException ex) {
       throw new SqoopException(DerbyRepoError.DERBYREPO_0027, ex);
     } finally {
-      closeStatements(stmt);
+      closeStatements(deleteStmt, updateStmt);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
index 8c0beeb..a895cfe 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
@@ -273,6 +273,10 @@ public final class DerbySchemaQuery {
     + ", " + COLUMN_SQNI_INPUT + ", " + COLUMN_SQNI_VALUE + ") "
     + "VALUES (?, ?, ?)";
 
+  public static final String STMT_UPDATE_CONNECTION =
+    "UPDATE " + TABLE_SQ_CONNECTION + " SET " + COLUMN_SQN_NAME + " = ? WHERE "
+    + COLUMN_SQN_ID + " = ?";
+
   // DML: Delete rows from connection input table
   public static final String STMT_DELETE_CONNECTION_INPUT =
     "DELETE FROM " + TABLE_SQ_CONNECTION_INPUT + " WHERE "
@@ -309,6 +313,10 @@ public final class DerbySchemaQuery {
     + ", " + COLUMN_SQBI_INPUT + ", " + COLUMN_SQBI_VALUE + ") "
     + "VALUES (?, ?, ?)";
 
+  public static final String STMT_UPDATE_JOB =
+    "UPDATE " + TABLE_SQ_JOB + " SET " + COLUMN_SQB_NAME + " = ? WHERE "
+      + COLUMN_SQB_ID + " = ?";
+
   // DML: Delete rows from job input table
   public static final String STMT_DELETE_JOB_INPUT =
     "DELETE FROM " + TABLE_SQ_JOB_INPUT + " WHERE " + COLUMN_SQBI_JOB + " = ?";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
index d189795..4121be7 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
@@ -160,6 +160,8 @@ public class TestConnectionHandling extends DerbyTestCase {
     forms = connection.getFrameworkPart().getForms();
     ((MStringInput)forms.get(1).getInputs().get(1)).setValue("Injected");
 
+    connection.setName("name");
+
     handler.updateConnection(connection, getDerbyConnection());
 
     assertEquals(1, connection.getPersistenceId());
@@ -167,6 +169,8 @@ public class TestConnectionHandling extends DerbyTestCase {
     assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 10);
 
     MConnection retrieved = handler.findConnection(1, getDerbyConnection());
+    assertEquals("name", connection.getName());
+
     forms = retrieved.getConnectorPart().getForms();
     assertEquals("Injected", forms.get(0).getInputs().get(1).getValue());
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f1893ab9/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
index 8ca7e46..c0e7a31 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
@@ -177,6 +177,8 @@ public class TestJobHandling extends DerbyTestCase {
     forms = job.getFrameworkPart().getForms();
     ((MStringInput)forms.get(1).getInputs().get(1)).setValue("Injected");
 
+    job.setName("name");
+
     handler.updateJob(job, getDerbyConnection());
 
     assertEquals(1, job.getPersistenceId());
@@ -184,6 +186,8 @@ public class TestJobHandling extends DerbyTestCase {
     assertCountForTable("SQOOP.SQ_JOB_INPUT", 18);
 
     MJob retrieved = handler.findJob(1, getDerbyConnection());
+    assertEquals("name", retrieved.getName());
+
     forms = retrieved.getConnectorPart().getForms();
     assertEquals("Injected", forms.get(0).getInputs().get(1).getValue());