File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes tables and fields 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 "tables and fields" Watch "tables and fields" New topic

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.

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
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]
I agree. Here's the link:
subject: tables and fields
jQuery in Action, 3rd edition