sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-741: The OracleConnect getTables() implementation needs to restrict tables to current user
Date Thu, 06 Dec 2012 16:52:20 GMT
Updated Branches:
  refs/heads/trunk 0b465594d -> 05774d49b


SQOOP-741: The OracleConnect getTables() implementation needs to restrict tables to current
user

(Venkat Ranganathan 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/05774d49
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/05774d49
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/05774d49

Branch: refs/heads/trunk
Commit: 05774d49bef891ba8552ed717cf2945161a75352
Parents: 0b46559
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Dec 6 08:51:41 2012 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Thu Dec 6 08:51:41 2012 -0800

----------------------------------------------------------------------
 .../org/apache/sqoop/manager/OracleManager.java    |   17 +++++++++-----
 1 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/05774d49/src/java/org/apache/sqoop/manager/OracleManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/OracleManager.java b/src/java/org/apache/sqoop/manager/OracleManager.java
index 22a057a..56244c7 100644
--- a/src/java/org/apache/sqoop/manager/OracleManager.java
+++ b/src/java/org/apache/sqoop/manager/OracleManager.java
@@ -82,7 +82,7 @@ public class OracleManager
    * ensure that the table can be operated on for import/export purposes.
    */
   public static final String QUERY_LIST_TABLES =
-    "SELECT TABLE_NAME FROM ALL_TABLES";
+    "SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER = ?";
 
   /**
    * Query to list all columns of the given table. Even if the user has the
@@ -654,15 +654,20 @@ public class OracleManager
   @Override
   public String[] listTables() {
     Connection conn = null;
-    Statement stmt = null;
+    PreparedStatement pStmt = null;
     ResultSet rset = null;
     List<String> tables = new ArrayList<String>();
+    String tableOwner = this.options.getUsername();
+
 
     try {
       conn = getConnection();
-      stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+      pStmt = conn.prepareStatement(QUERY_LIST_TABLES,
+          ResultSet.TYPE_FORWARD_ONLY,
               ResultSet.CONCUR_READ_ONLY);
-      rset = stmt.executeQuery(QUERY_LIST_TABLES);
+      pStmt.setString(1, tableOwner);
+
+      rset = pStmt.executeQuery();
 
       while (rset.next()) {
         tables.add(rset.getString(1));
@@ -683,9 +688,9 @@ public class OracleManager
           LOG.error("Failed to close resultset", ex);
         }
       }
-      if (stmt != null) {
+      if (pStmt != null) {
         try {
-          stmt.close();
+          pStmt.close();
         } catch (Exception ex) {
           LOG.error("Failed to close statement", ex);
         }


Mime
View raw message