ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [56/63] [abbrv] ambari git commit: AMBARI-21363 ORA-00911 error during Ambari server schema upgrade due to incorrect syntax of Update statement (dgrinenko)
Date Fri, 30 Jun 2017 13:38:46 GMT
AMBARI-21363 ORA-00911 error during Ambari server schema upgrade due to incorrect syntax of
Update statement (dgrinenko)


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

Branch: refs/heads/branch-feature-logsearch-ui
Commit: 4cd3150111560a43dd8028e6f14b2abf753e3d8b
Parents: 09e5d41
Author: Dmytro Grinenko <hapylestat@apache.org>
Authored: Thu Jun 29 15:17:29 2017 +0300
Committer: Dmytro Grinenko <hapylestat@apache.org>
Committed: Thu Jun 29 15:17:29 2017 +0300

----------------------------------------------------------------------
 .../ambari/server/orm/DBAccessorImpl.java       | 43 +++++++++++---------
 .../orm/helpers/dbms/GenericDbmsHelper.java     |  2 +-
 2 files changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd31501/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
index 83ea8e1..a88430b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
@@ -204,6 +204,27 @@ public class DBAccessorImpl implements DBAccessor {
     return objectName;
   }
 
+  /**
+   * Setting arguments for prepared statement
+   *
+   * @param preparedStatement {@link PreparedStatement} object
+   * @param arguments array of arguments
+   *
+   * @throws SQLException
+   */
+  private void setArgumentsForPreparedStatement(PreparedStatement preparedStatement, Object[]
arguments) throws SQLException{
+    for (int i = 0; i < arguments.length; i++) {
+      if (arguments[i] instanceof byte[]) {
+        byte[] binaryData = (byte[]) arguments[i];
+
+        // JDBC drivers supports only this function signature
+        preparedStatement.setBinaryStream(i+1, new ByteArrayInputStream(binaryData), binaryData.length);
+      } else {
+        preparedStatement.setObject(i+1, arguments[i]);
+      }
+    }
+  }
+
   @Override
   public boolean tableExists(String tableName) throws SQLException {
     boolean result = false;
@@ -878,16 +899,8 @@ public class DBAccessorImpl implements DBAccessor {
     LOG.info("Executing prepared query: {}", query);
 
     PreparedStatement preparedStatement = getConnection().prepareStatement(query);
+    setArgumentsForPreparedStatement(preparedStatement, arguments);
 
-      for (int i = 0; i < arguments.length; i++) {
-        if (arguments[i] instanceof byte[]) {
-          byte[] binaryData = (byte[]) arguments[i];
-          // JDBC drivers supports only this function signature
-          preparedStatement.setBinaryStream(i+1, new ByteArrayInputStream(binaryData), binaryData.length);
-        } else {
-          preparedStatement.setObject(i+1, arguments[i]);
-        }
-      }
     try {
         preparedStatement.execute();
     } catch (SQLException e) {
@@ -908,7 +921,7 @@ public class DBAccessorImpl implements DBAccessor {
    {@inheritDoc}
    */
   public void executePreparedUpdate(String query, Object...arguments) throws SQLException
{
-    executePreparedQuery(query, false, arguments);
+    executePreparedUpdate(query, false, arguments);
   }
 
   /**
@@ -918,16 +931,8 @@ public class DBAccessorImpl implements DBAccessor {
     LOG.info("Executing prepared query: {}", query);
 
     PreparedStatement preparedStatement = getConnection().prepareStatement(query);
+    setArgumentsForPreparedStatement(preparedStatement, arguments);
 
-    for (int i = 0; i <= arguments.length; i++) {
-      if (arguments[i] instanceof byte[]) {
-        byte[] binaryData = (byte[]) arguments[i];
-        // JDBC drivers supports only this function signature
-        preparedStatement.setBinaryStream(i+1, new ByteArrayInputStream(binaryData), binaryData.length);
-      } else {
-        preparedStatement.setObject(i+1, arguments[i]);
-      }
-    }
     try {
       preparedStatement.executeUpdate();
     } catch (SQLException e) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4cd31501/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
index 56274c5..e2a1f38 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
@@ -280,7 +280,7 @@ public class GenericDbmsHelper implements DbmsHelper {
    */
   @Override
   public String getColumnUpdateStatementWhereColumnIsNull(String tableName, String setColumnName,
String conditionColumnName){
-    return "UPDATE " + tableName + " SET " + setColumnName + "=? WHERE " + conditionColumnName
+ " IS NULL;";
+    return "UPDATE " + tableName + " SET " + setColumnName + "=? WHERE " + conditionColumnName
+ " IS NULL";
   }
 
   /**


Mime
View raw message