This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes DatabaseMetaData strange behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DatabaseMetaData strange behavior" Watch "DatabaseMetaData strange behavior" New topic

DatabaseMetaData strange behavior

Lukas Alamar
Ranch Hand

Joined: Mar 17, 2004
Posts: 68
hi ranchers
im a bit stuck on a problem so i need your help!

i have a very easy piece of code that uses a Connection and a DatabaseMetaData to retrieve tables and their columns .. so far so good .. for a bunch of tables the number of columns is doubled!! and i dont know why ..

then i get "MYTABLE cols=8" for .. say ..a table with only 4 cols ..

i know it may be trivial for some of you but that's my first attempt at using DatabaseMetaData

thanks for any help
[ March 28, 2006: Message edited by: Lukas Alamar ]

SCJP 1.4
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31571

I suspect there may be some hidden columns. The easiest way to confirm that or see what is going on is to print out colRset.getString("COLUMN_NAME") within your loop. Then you can see precisely what is being returned.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Lukas Alamar
Ranch Hand

Joined: Mar 17, 2004
Posts: 68
hi Jeanne,
thanks for your reply
i did what you suggested and here's the output for one of those weird tables:


obviously if i check the table with my db client i see only the first 4 columns!

most of the tables are correct .. this behavior is just for a few of them

(im feeling very ignorant ..)
[ March 30, 2006: Message edited by: Lukas Alamar ]
I agree. Here's the link:
subject: DatabaseMetaData strange behavior