Subject Re: [Firebird-Java] Strange behavior, possible bug with aliases in jaybird OR firebird
Author Mark Rotteveel
On 24-8-2010 13:28, Roman Rokytskyy wrote:
>> I am not sure, if I look at the jdbc API doc for getXxx methods, I would
>> say it is not:
>> "columnLabel - the label for the column specified with the SQL AS
>> clause. If the SQL AS clause was not specified, then the label is the
>> name of the column"
>
> Most likely there was a bug fix or feature request re. this
> functionality. One would need to check the source history.

I found JDBC-29 which requests a change that is incorrect against the
JDBC 4.0 spec, and JDBC-78 which was can be seen as a request to revert
to the behavior specified by JDBC 4.0 (but then by use of a separate
non-JDBC method).

I found the following an interesting read:
https://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.apdv.java.doc/doc/c0052593.html

Important in this regard is JDBC 4.0 section 15.2.3 which states:

"Two getter methods exist for each JDBC type: one that takes the column
index as its first parameter and one that takes the column label."

and

"Column labels supplied to getter methods are case insensitive. If a
select list contains the same column more than once, the first instance
of the column will be returned.
The index of the first instance of a column label can be retrieved using
the method findColumn. If the specified column is not found, the method
findColumn throws an SQLException."

If you combine this with the API doc of findColumn (see below), it is
clear that the current behavior is incorrect and violates the spec.

API doc of findColumn:
"
Maps the given ResultSet column label to its ResultSet column index.

Parameters:
columnLabel - the label for the column specified with the SQL
AS clause. If the SQL AS clause was not specified, then the label is the
name of the column
Returns:
the column index of the given column name
Throws:
SQLException - if the ResultSet object does not contain a
column labeled columnLabel, a database access error occurs or this
method is called on a closed result set
"

> I do not mind, if you create a ticket to not forget the issue.

I will create a ticket for it. If I have time I will also write a patch
for the current code.

BTW: Is CVS still leading for Jaybird, or did you switch to SVN?
--
Mark Rotteveel