Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

tables in the database

 
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.
 
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
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • 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
 
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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring 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.


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).
 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic