diff --git NOTICE NOTICE index 32d89b1..5c862df 100644 --- NOTICE +++ NOTICE @@ -9,3 +9,6 @@ Copyright (c) 2010-2014 Oracle and/or its affiliates. This project includes software copyrighted by Microsoft Corporation and licensed under the Apache License, Version 2.0. + +This project includes software copyrighted by Dell SecureWorks and +licensed under the Apache License, Version 2.0. diff --git itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java index b2dd2ab..90a3340 100644 --- itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java +++ itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java @@ -37,7 +37,10 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; +import java.sql.Timestamp; import java.sql.Types; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -2382,4 +2385,17 @@ public void testPrepareSetDate() throws Exception { fail(e.toString()); } } + + @Test + public void testPrepareSetTimestamp() throws SQLException, ParseException { + String sql = String.format("SELECT * FROM %s WHERE c20 = ?", dataTypeTableName); + try (PreparedStatement ps = con.prepareStatement(sql)) { + Timestamp timestamp = new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-01").getTime()); + ps.setTimestamp(1, timestamp); + try (ResultSet resultSet = ps.executeQuery()) { + assertTrue(resultSet.next()); + assertEquals("2013-01-01", resultSet.getString(20)); + } + } + } } diff --git jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java index 7687537..81c3d5d 100644 --- jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java +++ jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java @@ -728,7 +728,7 @@ public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLExceptio */ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { - this.parameters.put(parameterIndex, x.toString()); + this.parameters.put(parameterIndex, "'" + x.toString() + "'"); } /*