/** * Full JVM settings and connection string: * -Xmx512M -XX:+UseParallelGC -Dcom.mysql.jdbc.testsuite.url.default=jdbc:mysql://localhost:3306/test?user=root&password=*****&autoReconnect=false&initialTimeout=1&connectTimeout=2000&jdbcCompliantTruncation=false */ package testsuite.simple; import java.sql.Connection; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.Properties; import java.sql.Statement; import testsuite.BaseTestCase; /** * @author Tonci * */ public class TestBug36327 extends BaseTestCase { /** * @param name */ public TestBug36327(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug36327() 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")); try { createTable("bug36327", "(fid varchar(255) not null primary key, id INT)"); if (versionMeetsMinimum(5, 0, 7)) { Properties props = new Properties(); props.put("useOldAliasMetadataBehavior", "true"); Connection conn1 = null; try { conn1 = getConnectionWithProps(props); this.rs = this.stmt.executeQuery("select a1.fid AS Field0, a1.id AS Field1 FROM bug36327 AS a1"); ResultSetMetaData metaData = this.rs.getMetaData(); ////assertEquals("useOld-GetColLabel0 failed", "fid", metaData.getColumnLabel(1)); //NOT sure what goes here... assertEquals("useOld-GetColName0 failed", "Field0", metaData.getColumnName(1)); ////assertEquals("useOld-GetColLabel1 failed", "id", metaData.getColumnLabel(1)); //NOT sure what goes here... assertEquals("useOld-GetColName1 failed", "Field1", metaData.getColumnName(1)); System.out.println("useOld-GetTblName1: "+ metaData.getTableName(2)); this.rs.close(); //------------------------------------------- Properties props2 = new Properties(); props2.put("useOldAliasMetadataBehavior", "false"); Connection conn2 = null; try { conn2 = getConnectionWithProps(props2); Statement stmt2 = conn2.createStatement(); ResultSet rs2 = stmt2.executeQuery("select a1.fid AS Field0, a1.id AS Field1 FROM bug36327 AS a1"); ResultSetMetaData metaData2 = rs2.getMetaData(); assertEquals("NOTuseOld-GetColLabel0 failed", "Field0", metaData2.getColumnLabel(1)); assertEquals("NOTuseOld-GetColName0 failed", "fid", metaData2.getColumnName(1)); assertEquals("NOTuseOld-GetColLabel1 failed", "Field1", metaData2.getColumnLabel(2)); assertEquals("NOTuseOld-GetColName1 failed", "id", metaData.getColumnName(2)); System.out.println("NOTuseOld-GetTblName1: "+ metaData2.getTableName(2)); stmt2.close(); rs2.close(); } finally { if (conn2 != null) { conn2.close(); } } } 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(TestBug36327.class); } }