hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sunc...@apache.org
Subject [37/50] [abbrv] hive git commit: HIVE-11024: Error inserting a date value via parameter marker (PreparedStatement.setDate) (Yongzhi Chen, reviewed by Sergio Pena)
Date Mon, 20 Jul 2015 20:12:47 GMT
HIVE-11024: Error inserting a date value via parameter marker (PreparedStatement.setDate) (Yongzhi
Chen, reviewed by Sergio Pena)


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

Branch: refs/heads/spark
Commit: e74dc320ed4c2cae0ab34cf89fb695c1a5f2e31f
Parents: e2ee458
Author: Sergio Pena <sergio.pena@cloudera.com>
Authored: Thu Jul 16 07:28:16 2015 -0500
Committer: Sergio Pena <sergio.pena@cloudera.com>
Committed: Thu Jul 16 07:28:16 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/hive/jdbc/TestJdbcDriver2.java  | 16 ++++++++++++++++
 .../org/apache/hive/jdbc/HivePreparedStatement.java |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/e74dc320/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
index e4b9cd7..b2dd2ab 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
@@ -2366,4 +2366,20 @@ public void testParseUrlHttpMode() throws SQLException, JdbcUriParseException,
       assertTrue(accumulatedLogs.contains(expectedLog));
     }
   }
+  @Test
+  public void testPrepareSetDate() throws Exception {
+    try {
+      String sql = "select * from " + dataTypeTableName + " where c20 = ?";
+      PreparedStatement ps = con.prepareStatement(sql);
+      java.sql.Date dtValue = java.sql.Date.valueOf("2013-01-01");
+      ps.setDate(1, dtValue);
+      ResultSet res = ps.executeQuery();
+      assertTrue(res.next());
+      assertEquals("2013-01-01", res.getString(20));
+      ps.close();
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.toString());
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/e74dc320/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java b/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
index 2625155..7687537 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java
@@ -436,7 +436,7 @@ public class HivePreparedStatement extends HiveStatement implements PreparedStat
    */
 
   public void setDate(int parameterIndex, Date x) throws SQLException {
-    this.parameters.put(parameterIndex, x.toString());
+    this.parameters.put(parameterIndex, "'" + x.toString() + "'");
   }
 
   /*


Mime
View raw message