Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
with
69 additions
and 0 deletions.
@@ -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(); | ||
} | ||
} |