/*
* Copyright (c) 2004, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
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();
}
}