jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes want toknow all the object names in a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "want toknow all the object names in a database" Watch "want toknow all the object names in a database" New topic

want toknow all the object names in a database

harjit bedi

Joined: Dec 09, 2000
Posts: 3
hi friends,
what all i want is what query should i fire to get all the object names like tables,vies etc in a database.
in oracle it is
"select * from cat" or "select * from tab"
but I want to know the exact query for MS-access or SQL-server.
thanks in advance.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
I would suggest a visit to the Microsoft online documentation to see what they call their system tables.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
seema kamath

Joined: Nov 27, 2000
Posts: 14
hi harjit,
i think i can try helping u
There is this method called getMetaData() in Connection interface that gives you info about the database. call this method.This returns an object of DatabaseMetaData .
just say,
DatabaseMetaData dmeta= con.getMetaData();
//con in of Connection
The method getTables of DtabaseMetaData gives all the objects associated with a specific database
ResultSet rs= dmets.getTables(null,null,"%",null)
where the paramter 1 represesnts the schema
2 represents the catalog
3 represents the patterns of table desired
4 represents the types of tables(system,view,general etc
then iterate thru the resultset as usual and using the getSrting(n) where n is the column number get the appropriate name of the object.
this should do.and i hope i have solved your problem
And people,please free to correct me,if i'am wrong.
seema kamath
Amit Manurkar

Joined: Apr 03, 2003
Posts: 11
Hey Folks,
First of all thanks a lot for this post of yours, it helped me a lot.
I would like to know if you have any idea about this - I want to query the system tables directly e.g "MSysRelationships" how can I do that ? I tried to query the tables directly using the "executeQuery()" method of the "Statement" object, but it does not allow me to access System tables.

Amit Manurkar
Have you checked out Aspose?
subject: want toknow all the object names in a database
It's not a secret anymore!