• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tables in the database

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
reply
    Bookmark Topic Watch Topic
  • New Topic