/** * */ package testsuite.simple; import java.sql.Connection; import java.util.Properties; import testsuite.BaseTestCase; /** * @author Tonci * */ public class TestBug38244 extends BaseTestCase { /** * @param name */ public TestBug38244(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug38244() throws Exception { System.out.println("java.vm.version : " + System.getProperty("java.vm.version")); System.out.println("java.vm.vendor : " + System.getProperty("java.vm.vendor")); System.out.println("java.runtime.version : " + System.getProperty("java.runtime.version")); System.out.println("os.name : " + System.getProperty("os.name")); System.out.println("os.version : " + System.getProperty("os.version ")); System.out.println("sun.management.compiler : " + System.getProperty("sun.management.compiler")); Connection rewriteConn = null; Properties props = new Properties(); props.put("jdbcCompliantTruncation","true"); props.put("useInformationSchema","true"); try { createTable("bug38244", "(c BIT(10))"); System.out.println("Test 1.1: jdbcCompliantTruncation=true, useInformationSchema=true"); byte[] b = null; rewriteConn = getConnectionWithProps(props); this.stmt = rewriteConn.createStatement(); this.stmt.execute("INSERT INTO bug38244 VALUES (111)"); this.pstmt = rewriteConn.prepareStatement("SELECT * FROM bug38244"); this.rs = this.pstmt.executeQuery(); while (this.rs.next()) { System.out.println(this.rs.getObject(1).getClass().getName()); b = (byte[])rs.getObject(1); for (byte bb: b) System.out.println(bb); } this.pstmt = rewriteConn.prepareStatement("update bug38244 set c=222 where c = ?"); this.pstmt.setBytes(1, b); int i = this.pstmt.executeUpdate(); System.out.println("Update count (i) = " + i); System.out.println("Update count = " + this.pstmt.getUpdateCount()); this.rs.close(); this.stmt.close(); this.pstmt.close(); rewriteConn.close(); props.clear(); props.put("jdbcCompliantTruncation", "false"); props.put("useInformationSchema","true"); System.out.println("Test 1.2: jdbcCompliantTruncation=false, useInformationSchema=true"); rewriteConn = getConnectionWithProps(props); this.pstmt = rewriteConn.prepareStatement("SELECT * FROM bug38244"); this.rs = this.pstmt.executeQuery(); while (this.rs.next()) { System.out.println(this.rs.getObject(1).getClass().getName()); b = (byte[])rs.getObject(1); for (byte bb: b) System.out.println(bb); } this.pstmt = rewriteConn.prepareStatement("update bug38244 set c=333 where c = ?"); this.pstmt.setBytes(1, b); i = this.pstmt.executeUpdate(); System.out.println("Update count (i) = " + i); System.out.println("Update count = " + this.pstmt.getUpdateCount()); this.rs.close(); this.stmt.close(); this.pstmt.close(); rewriteConn.close(); props.clear(); } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug38244.class); } }