/** * TonĨi */ package testsuite.simple; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.Statement; import java.util.Properties; import testsuite.BaseTestCase; public class TestBug43666 extends BaseTestCase { public TestBug43666(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug43666() 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("`bug43666a`", "(Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;"); createTable("`bug43666b`", "(Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, IdTableA INT NOT NULL, FOREIGN KEY fk1(IdTableA) References bug43666a(Id)) ENGINE=InnoDB;"); Properties props = new Properties(); Connection conn1 = null; try { conn1 = getConnectionWithProps(props); Statement stm = conn1.createStatement(); stm.execute("SET SQL_MODE = ''"); DatabaseMetaData dbmd = conn1.getMetaData(); this.rs = dbmd.getExportedKeys("test", "test", "bug43666a"); this.rs.first(); assertTrue("No rows returned", this.rs.isFirst()); this.rs.close(); stm.execute("SET SQL_MODE = 'ANSI_QUOTES'"); dbmd = conn1.getMetaData(); this.rs = dbmd.getExportedKeys("test", "test", "bug43666a"); this.rs.first(); assertTrue("No rows returned with ANSI_QUOTES", this.rs.isFirst()); this.rs.close(); conn1.close(); props.put("useInformationSchema","true"); conn1 = getConnectionWithProps(props); stm = conn1.createStatement(); stm.execute("SET SQL_MODE = ''"); dbmd = conn1.getMetaData(); this.rs = dbmd.getExportedKeys("test", "test", "bug43666a"); this.rs.first(); assertTrue("No rows returned, Use Information schema", this.rs.isFirst()); this.rs.close(); }finally { //create table sequence must be a than b //drop table must be reverse, b then a thus below lines this.stmt.execute("DROP TABLE IF EXISTS `bug43666b`"); this.stmt.execute("DROP TABLE IF EXISTS `bug43666a`"); if (conn1 != null) { conn1.close(); } } } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug43666.class); } }