This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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
internet detective

Joined: May 26, 2003
Posts: 30136

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.

[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
Similar Threads
How to find the column names..???
Memory Leaks
JDBC DB-Converter
Error java util NoSuchElementException
Columns on JTable