• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get table names ?

 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using oracle 9i, how can i get the list of table in a particular database. i have seen few posts in the forum and tried according to that, but no luck still.

My database configuration is,

sid = web
username = scot
password = tiger
database name = test

I am trying to use DatabaseMetaData.getTables(String,String,String,String)

what is catalog in my context
what is schemaPattern in my context
what is tableNamePattern in my context
what is columnNamePattern in my context

I understand from the previous posts that, the ResultSetMetaData.tableName(int) is not working with Oracle.

I hope you guys understand my problem, I am very new in DBMS.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sanju,

do you want know table names in java or on sql plus
if sql plus then this query will do the job




shailesh
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to know in java, using JDBC.
 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ResultSet rset;

.....

rset.getMetaData() has a bunch of access functions
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using ResultSetMetaData, ResultSetMetaData.getTableName(int) is not working with oracle ojdbc14 drivers. and tried using DatabaseMetaData.

The code is,



I want to know, what I should use instead of xxxx in the method params. please see my database infos in the first post.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[This was typed and posted before Sanjus's above Post]


Originally posted by -Sanju Thomas-:
I wanted to know in java, using JDBC.


1) Create the Connection to Database
2) Invoke the method getMetaData()

DatabaseMetaData dm = conection.getMetaData()

3) Now you have DatabaseMetaData (dm)invoke the dm.getTables()

catalog -- pass this as connection.getCatalog()
SchemaPattern -- your schmea patters
tableNamePattern -- pattern name for lable for example you need table starting with 'S' so pass it as 'S%'
types -- list of table types to include

you will get a resultset of tables and you can get table names as rs.getString("TABLE_NAME")


for more detail refer javadoc.


hope this helps

Shailesh
[ April 15, 2005: Message edited by: Shailesh Chandra ]
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by -Sanju Thomas-:

I want to know, what I should use instead of xxxx in the method params. please see my database infos in the first post.


Sanju,

As I mentioned in my last post these are the parameter to narrow the search
for catalog,schemaPattern and types you can pass null they would not be consider to narrow your search

and for table name pattern I am not sure but you pass it as "%" this should retrun all table.

Shailesh
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Thank you very much Shailesh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic