aspose file tools*
The moose likes JDBC and the fly likes field name problems with joins in Oracle JDBC thin driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "field name problems with joins in Oracle JDBC thin driver" Watch "field name problems with joins in Oracle JDBC thin driver" New topic
Author

field name problems with joins in Oracle JDBC thin driver

Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Hi All,
can I do this in Oracle JDBC:
SELECT project.*, lead.*, second.*
FROM project, person lead, person second
WHERE project.lead_person_id = lead.id
AND project.second_person_id = second.id
And then somehow use ResultSet.getString("lead.name") and get the field value using the column name rather than the column index?
Ideally I want to be able to avoid naming the fields in the SELECT clause, only in the getString()
I played around all afternoon trying to get something like this to work, checking out the Oracle docs and so on, but I can't manage it. I want to encapsulate the field names in specific classes in my database access objects.
It seems though I have to give the field names aliases in the SELECT clause - is that so? Is there no way I can do it with table aliases?
Thanks for any tips,
Adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
It's typically much faster to use the column indexes as opposed to column names.


James Carman, President<br />Carman Consulting, Inc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: field name problems with joins in Oracle JDBC thin driver