Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DatabaseMetaData

 
E Wong
Greenhorn
Posts: 6
  • 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
  • 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
  • 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