Get the columns returned by ID, not name (recommended best practice). If you get the columns out of order your code is not guaranteed to work (strange, but true).
If you don't like that idea, try A.*, B.* instead of plain old *. I don't think that'll achieve much though
Check the ResultSetMetaData and get the column name actually being returned. You can probably find this out by running the query directly against your database and seeing what the column headings come out like.
I am having the same problem. I am having 2 tables which has several columns which has the same name.
for ex select * from tab1 t1,tab2 t2; let us say that tab1 and tab2 has same column names ex: col1 and col2.
when i try to access without a fully qualified table name then i am getting the value of the second table.
so for ex if i say resultset.getString("col1"). then i get the value of the tab2 col2. but when i query the DB directly then the order of column is same as expected meaning it gives tab1.col1.
if i use fully qualified name then it says that the column name was not fond.
did anybody into this kind of problem.
i am using postrgres 8.3.3. on windows OS.
any help is appreciated.
Wow reviving a dead thread. Anyway, I disagree about getting by ID being a best practice, its a recipe for disaster in my experience. Bauke is correct about "SELECT *" that should never be in a line of code, ever. When in doubt you can always re-write your query as "SELECT x.myVal AS somethingElse FROM myTable x,...." or some such variation.
if you so not have control over the query being used....try WebRowSet Interface.. it can give you all information about the meta data in xml format. you can use this xml to get which index in resultset belongs to column of which table.
ResultSet rs = stmt.executeQuery("select * from user, admin where user.firstname = admin.firstname");