Bug #66474 I can not give an alias using the AS clause to column
Submitted: 21 Aug 2012 2:52 Modified: 17 Sep 2012 6:51
Reporter: makoto sugimoto Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.18, 5.1.21 OS:Other (CentOS)
Assigned to: Alexander Soklakov CPU Architecture:Any
Tags: connector

[21 Aug 2012 2:52] makoto sugimoto
Description:
An error occurs when an alias using the "AS" in the column.
If this aliased using the "AS" to a fixed string time and the system does not result in an error.

Env
 OS:CentOS
 MySQLVesion:5.5.23
 MySQLConnectorVersion:
   mysql-connector-java-5.0.8-bin.jar   => No problem,
   mysql-connector-java-5.1.18-bin.jar  => Error,
   mysql-connector-java-5.1.21-bin.jar  => Error

SQL
 SELECT id as aaaa FROM documenttable         => Error
 SELECT "exsample" as aaaa FROM documenttable => No problem
 SELECT sysdate() as aaaa FROM documenttable  => No problem

Error Message
 java.sql.SQLException: Column 'idfield' not found.
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
	at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1144)
	at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5610)
	at DbTest.main(DbTest.java:56)
Exception in thread "main" java.sql.SQLException: Column 'idfield' not found.
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
	at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1144)
	at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5610)
	at DbTest.main(DbTest.java:56)

How to repeat:
You can reproduce the issue if you can use it with a later version MySQLConnector5.1.
[6 Sep 2012 7:52] Alexander Soklakov
Hello Makoto,

Thanks for your report.

I was not able to reproduce the problem with 5.1.21 c/J. Please, ensure that it isn't a typo, I don't see 'idfield' identifier in SELECTs in your example. Provide your test case if it isn't.
[10 Sep 2012 5:44] makoto sugimoto
Hello, Alexander

Thank you for the survey.

Since I've lost the source when you reproduce
Was run by another source, I was able to run without any problems for sure.

However, an error has occurred is in another application.
Maybe there is an error condition
I am going to investigate a little more.

THANK YOU
[17 Sep 2012 6:51] Alexander Soklakov
Hello Makoto,

OK, feel free to reopen this bug if you will get a repeatable test case.

Thanks.