• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding DatabaseMetaData interface

 
siddique sikkander
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friend,
I am sidiq.
I am working as java developer.
I have question regarding java interface DatabaseMetaData.
Below code is getting the column to the table namely OATSSEND.
I known that OATSSEND table has only one column namely OATS_SEND_DATA.
After following code ran I got ResultSet of size is 2 with same OATS_SEND_DATA was printed twice.

Please give me an idea why I got column size 2 and it has printed column name twice.

Thanking you,
Sidiq
[ April 30, 2008: Message edited by: Scott Selikoff ]
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried sending "%" as the second and forth parameters? I'm not sure null is permitted here. Also, why only output the size while debugging? Why not read the column information as it should shed some light on why it returned the two records.
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Per the API for DatabaseMetaData:

For the second parameter (schemaPattern): must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search

The fourth parameter (columnNamePatter): must match the column name as it is stored in the database
 
siddique sikkander
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. Even I tried by using �% �for second and fourth arguments. Now I got ResultSet size (Return no of column in the querying table) more then 5 now. But I am expecting column size is 1. Please let me know if you get any idea.

Thanking you,
Sidiq
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, why are you only printing the size???

You could print the entire record in the while loop which should shed some light on whats going on. If you stick with just printing the number, we could spend days guessing about the solution.
[ April 30, 2008: Message edited by: Scott Selikoff ]
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siddique,

Scott's right, you really want to check that the columns you're getting are what you expect.

You can have multiple tables across the entire database with the same name. Check the TABLE_SCHEM for each returned column, for example, to make sure you're getting the specific table and only the specific table you want.
 
siddique sikkander
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Scott Selikoff /Stevi Deter
Thanks for reply. I tried to print all ResultSet information. It is true that the there is two schema in my database which have the same table name OATSSEND. That why I got same column two time. Now I narrowed my search by using schema name also instead of by passing null argument. Now I got result as I expected. Thanks for your suggestion.

Thanking you,
Sidiq
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic