/** * */ package testsuite.simple; import java.math.BigInteger; import java.sql.Connection; import java.sql.ResultSetMetaData; import java.sql.Statement; import java.util.Properties; import testsuite.BaseTestCase; public class TestBug43196 extends BaseTestCase { public TestBug43196(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug43196() throws Exception { try { 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 : " + System.getProperty("os.name") + ", " + System.getProperty("os.version") + ", " + System.getProperty("os.arch")); System.out.println("sun.management.compiler : " + System.getProperty("sun.management.compiler")); System.out.println("-------------------------------------------------"); createTable("`bug43196`", "(`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, `a` bigint(20) unsigned NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Properties props = new Properties(); props.put("jdbcCompliantTruncation", "true"); props.put("useInformationSchema","true"); Connection conn1 = null; try { conn1 = getConnectionWithProps(props); assertEquals(1, this.stmt.executeUpdate("INSERT INTO bug43196 (a) VALUES (1)", Statement.RETURN_GENERATED_KEYS)); this.rs = this.stmt.getGeneratedKeys(); if(this.rs.next()){ Long id = (Long) this.rs.getObject(1) ;//use long } this.rs.close(); this.rs = this.stmt.executeQuery("select id from bug43196"); if(this.rs.next()){ BigInteger id = (BigInteger) this.rs.getObject(1);//use BigInteger } this.rs.close(); //insert a id > Long.MAX_VALUE(9223372036854775807) assertEquals(1, this.stmt.executeUpdate("insert into bug43196(id,a) values(18446744073709551200,1)",Statement.RETURN_GENERATED_KEYS)); this.rs = this.stmt.getGeneratedKeys(); this.rs.first(); assertTrue("No rows returned", this.rs.isFirst()); }finally { if (conn1 != null) { conn1.close(); } } } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug43196.class); } }