Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Regarding DatabaseMetaData interface

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 4323
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4323
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic