Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResultSet.getXxx(String), ResultSet.findColumn(String) not JDBC 4.0 compliant [JDBC161] #204

Closed
firebird-automations opened this issue Aug 24, 2010 · 6 comments

Comments

@firebird-automations
Copy link

Submitted by: @mrotteveel

Assigned to: Roman Rokytskyy (rrokytskyy)

Attachments:
ColumnLabelGetTest.java

The current behavior of ResultSet.getXxx(String) eg ResultSet.getString(String) and ResultSet.findColumn(String) are not JDBC 4.0 compliant.

Example query:
SELECT CUST_NO, CUSTOMER AS CST_NAME FROM CUSTOMER

Expected:
getXxx("CUST_NO") returns the value (of col 1)
getXxx("CST_NAME") return the value (of col 2)
getXxx("CUSTOMER") throws a SQLException
findColumn("CUST_NO") returns 1
findColumn("CST_NAME") returns 2
findColumn("CUSTOMER") throws a SQLException

Current behavior:
getXxx("CUST_NO") returns the value (of col 1)
getXxx("CST_NAME") return the value (of col 2)
getXxx("CUSTOMER") returns the value (of col 2)
findColumn("CUST_NO") returns 1
findColumn("CST_NAME") returns 2
findColumn("CUSTOMER") returns 2

The JDBC 4.0 spec says (15.2.3):
{quote}
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.
{quote}
and
{quote}
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.
{quote}

The JDBC 4.0 API doc states for ResultSet.findColumn:
{quote}
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

{quote}

and for ResultSet.getString(String):
{quote}
Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.

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 value; if the value is SQL NULL, the value returned is null 
Throws:
    SQLException \- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set

{quote}

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Test (package firebird.reproduction) that tests basic cases. Two of them fail right now:
* testFindColumnUseNameWithAlias
* testGetStringUseNameWithAlias

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Attachment: ColumnLabelGetTest.java [ 11720 ]

@firebird-automations
Copy link
Author

Commented by: Roman Rokytskyy (rrokytskyy)

Duplicate with JDBC162

@firebird-automations
Copy link
Author

Modified by: Roman Rokytskyy (rrokytskyy)

Fix Version: Jaybird 2.2 [ 10053 ]

timeestimate: 0 [ 0 ]

timeoriginalestimate: 0 [ 0 ]

@firebird-automations
Copy link
Author

Modified by: Roman Rokytskyy (rrokytskyy)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Duplicate [ 3 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant