File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DatabaseMetaData

 
E Wong
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

if COUNT_OF_TABLES == 0{
conn.close();

Hope someone can shed some light

Best regards,
E Wong
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is it better to use a vendor-specific solution?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic