package testsuite.simple; import java.sql.Timestamp; import java.util.Date; import testsuite.BaseTestCase; public class TestBug21438 extends BaseTestCase{ public TestBug21438(String name) { super(name); } /** * Tests BUG#21438, server-side PS fails when using jdbcCompliantTruncation. * If either is set to FALSE (&useServerPrepStmts=false or * &jdbcCompliantTruncation=false) test succedes. * * @throws Exception * if the test fails. */ public void testbug21438() throws Exception { createTable("test_table","(t_id int(10), test_date timestamp(30) NOT NULL,primary key t_pk (t_id));"); assertEquals(1, this.stmt.executeUpdate("insert into test_table values (1,NOW());")); this.conn.setAutoCommit (false); this.pstmt = this.conn .prepareStatement("UPDATE test_table SET test_date=ADDDATE(?,INTERVAL 1 YEAR) WHERE t_id=1;"); try { Timestamp ts = new Timestamp(new Date().getTime()); System.out.println("Reported TS:" + ts.toString()); this.pstmt.setTimestamp(1, ts);//new Timestamp(new Date().getTime()) System.out.println("Query to be executed: "+pstmt.toString()); assertEquals(1, this.pstmt.executeUpdate()); this.pstmt.clearParameters(); this.conn.commit(); } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { junit.textui.TestRunner.run(TestBug21438.class); } public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } }