Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

field name problems with joins in Oracle JDBC thin driver

 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's typically much faster to use the column indexes as opposed to column names.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic