Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tables in the database

 
pranay ahlawat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get all the tables/views stored in the database.

(If possible know all the datbases that the driver is serving).
How do I do this.

Which metadata class / any sql query?

Thanks a lot.
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Check out the DataBaseMetaData interface in the java.sql.package. I think that will solve ur problem. Let me know if u need more help

Regards
Makarand Parab
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pranay ahlawat:
any sql query?



On oracle you can exeute query on ALL_OBJECTS
and on sql server I am not sure abouth this but you can check in Information_schema

Shailesh
 
Anand Karia
Ranch Hand
Posts: 156
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi pranay ahlawat

This is only possible if you clearly define which database you are using. Because there are different ways to solve the same in different database.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15642
47
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi pranay ahlawat

This is only possible if you clearly define which database you are using. Because there are different ways to solve the same in different database.

No, that is not necessary. As Makarand Parab already pointed out, you can do this by looking at the database metadata that you can get by calling the method java.sql.Connection.getMetaData(). Look it up in the API documentation. Class DatabaseMetaData has a method getTables() to get all the tables in the database (that the user with which you logged in into the database has access to).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic