It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes DatabaseMetaData Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DatabaseMetaData" Watch "DatabaseMetaData" New topic


E Wong

Joined: Sep 20, 2004
Posts: 6
Hi there, does anyone know of any methods that i could use to count the amount of tables that exist in a database.

What i'm basically trying to do is


Hope someone can shed some light

Best regards,
E Wong
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You can look at the catalogs (see java.sql.DatabaseMetaData methods). But in this instance you miught be better off just using DB specific SQL, e.g.
"show tables;" in MySQL, or querying the sysobject table in MSSQL etc.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Why is it better to use a vendor-specific solution?
I agree. Here's the link:
subject: DatabaseMetaData
It's not a secret anymore!