File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DatabaseMetaData strange behavior" Watch "DatabaseMetaData strange behavior" New topic
Author

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
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Lukas,
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:

WEIRD_TABLE
C_KEY
N_PRG
T_DES
D_TMP_INS
C_KEY
N_PRG
T_DES
D_TMP_INS

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: http://aspose.com/file-tools
 
subject: DatabaseMetaData strange behavior