Permalink
Browse files

feat: support java.sql.Types.TIME_WITH_TIMEZONE and java.sql.Types.TI…

…MESTAMP_WITH_TIMEZONE in setNull method

closes #570
  • Loading branch information...
tminglei authored and vlsi committed May 18, 2016
1 parent 32d4e08 commit 1b73bf6efa8879943987f79d1084c419200ccca9
@@ -241,6 +241,10 @@ public void setNull(int parameterIndex, int sqlType) throws SQLException {
oid = Oid.DATE;
break;
case Types.TIME:
//#if mvn.project.property.postgresql.jdbc.spec >= "JDBC4.2"
case Types.TIME_WITH_TIMEZONE:
case Types.TIMESTAMP_WITH_TIMEZONE:
//#endif
case Types.TIMESTAMP:
oid = Oid.UNSPECIFIED;
break;
@@ -17,6 +17,7 @@
SimpleJdbc42Test.class,
CustomizeDefaultFetchSizeTest.class,
GetObject310Test.class,
PreparedStatementTest.class,
GetObject310BinaryTest.class,
SetObject310Test.class})
public class Jdbc42TestSuite {
@@ -0,0 +1,64 @@
/*-------------------------------------------------------------------------
*
* Copyright (c) 2004-2014, PostgreSQL Global Development Group
*
*
*-------------------------------------------------------------------------
*/

package org.postgresql.test.jdbc42;

import org.postgresql.test.TestUtil;
import org.postgresql.test.jdbc2.BaseTest;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;


public class PreparedStatementTest extends BaseTest {

public PreparedStatementTest(String name) {
super(name);
}

protected void setUp() throws Exception {
super.setUp();
TestUtil.createTable(con, "timestamptztable", "tstz timestamptz");
TestUtil.createTable(con, "timetztable", "ttz timetz");
}

protected void tearDown() throws SQLException {
TestUtil.dropTable(con, "timestamptztable");
TestUtil.dropTable(con, "timetztable");
super.tearDown();
}

public void testTimestampTzSetNull() throws SQLException {
PreparedStatement pstmt = con.prepareStatement("INSERT INTO timestamptztable (tstz) VALUES (?)");

// valid: fully qualified type to setNull()
pstmt.setNull(1, Types.TIMESTAMP_WITH_TIMEZONE);
pstmt.executeUpdate();

// valid: fully qualified type to setObject()
pstmt.setObject(1, null, Types.TIMESTAMP_WITH_TIMEZONE);
pstmt.executeUpdate();

pstmt.close();
}

public void testTimeTzSetNull() throws SQLException {
PreparedStatement pstmt = con.prepareStatement("INSERT INTO timetztable (ttz) VALUES (?)");

// valid: fully qualified type to setNull()
pstmt.setNull(1, Types.TIME_WITH_TIMEZONE);
pstmt.executeUpdate();

// valid: fully qualified type to setObject()
pstmt.setObject(1, null, Types.TIME_WITH_TIMEZONE);
pstmt.executeUpdate();

pstmt.close();
}
}

0 comments on commit 1b73bf6

Please sign in to comment.