/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/J is licensed under the terms of the GPLv2 , like most MySQL Connectors. There are special exceptions to the terms and conditions of the GPLv2 as it is applied to this software, see the FLOSS License Exception . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package testsuite.simple; import java.sql.Connection; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; import testsuite.BaseTestCase; 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")); if (versionMeetsMinimum(5, 0, 7)) { createTable("bug36327", "(fid varchar(255) not null primary key, id INT)"); String sql = "select a1.fid AS Field0, a1.id AS Field1 FROM bug36327 AS a1"; Connection conn1 = null; Connection conn2 = null; try { conn1 = getConnectionWithProps("useOldAliasMetadataBehavior=true"); Statement stmt1 = conn1.createStatement(); ResultSet rs1 = stmt1.executeQuery(sql); ResultSetMetaData metaData1 = rs1.getMetaData(); assertEquals("useOld-GetColLabel0 failed", "Field0", metaData1.getColumnLabel(1)); assertEquals("useOld-GetColLabel1 failed", "Field1", metaData1.getColumnLabel(2)); assertEquals("useOld-GetColName1 failed", "Field0", metaData1.getColumnName(1)); assertEquals("useOld-GetColName2 failed", "Field1", metaData1.getColumnName(2)); assertEquals("useOld-GetTblName1 failed", "a1", metaData1.getTableName(1)); assertEquals("useOld-GetTblName2 failed", "a1", metaData1.getTableName(2)); conn2 = getConnectionWithProps("useOldAliasMetadataBehavior=false"); Statement stmt2 = conn2.createStatement(); ResultSet rs2 = stmt2.executeQuery(sql); ResultSetMetaData metaData2 = rs2.getMetaData(); assertEquals("NOTuseOld-GetColLabel0 failed", "Field0", metaData2.getColumnLabel(1)); assertEquals("NOTuseOld-GetColLabel1 failed", "Field1", metaData2.getColumnLabel(2)); assertEquals("NOTuseOld-GetColName0 failed", "fid", metaData2.getColumnName(1)); assertEquals("NOTuseOld-GetColName1 failed", "id", metaData2.getColumnName(2)); assertEquals("NOTuseOld-GetTblName1 failed", "bug36327", metaData2.getTableName(1)); assertEquals("NOTuseOld-GetTblName2 failed", "bug36327", metaData2.getTableName(2)); } finally { if (conn1 != null) { conn1.close(); } if (conn2 != null) { conn2.close(); } } } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug36327.class); } }