columns with same name gives "column not found"

I'm using ODBC to retreive data from MS Access. Something like:

SELECT x.*, y.Key, z.Key FROM x, y, z

When I do a ResultSet.getString("y.Key") I get a sql exception, "Column not found".

There is a "Key" column in each table, but when I try to use the "table.column" format, I get this exception. Even my Professional JSP book shows this works.

I don't want to use the column number since I use the x.* select.

Any help would be great. Thanks.

/paul

[500 byte] By [pcarver] at [2007-9-26 2:16:43]
# 1

Either it's a restriction of the JDBC-ODBC bridge or of the MS ODBC (MDAC and so on).

Use instead:

getString( 1 ) for the first column, ...

It has never been good style to use select *.

Enumerate exactly those columns you want to retrieve, and retrieve them just in this order (also that can be important! I get errors even with MS SQLServer, if I don't hold on that!), that's the best approach.

Hartmut at 2007-6-29 9:15:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...