This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes tables and fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "tables and fields" Watch "tables and fields" New topic
Author

tables and fields

Xinyi Zhang
Ranch Hand

Joined: Apr 28, 2001
Posts: 42
How to list tables in specific database and how to find field name and its data type using Java program? Thanks.


Xinyi
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
See the javadocs on java.sql.Connection#getMetaData(). Calling myConnection.getMetaData().getTables(null, null, null, null) should return all tables.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: tables and fields
 
Similar Threads
Joins
2 tables
hibenrate Query...
Increasing performance through indexing
JDBC doesn't retrieve all the results available in the MSSQL database