Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java: MySQL getting tables and information within Java Code

Posted on 2004-10-05
2
Medium Priority
?
208 Views
Last Modified: 2010-03-31
I have successfully managed to install MySQL and open up a database I have created.

I want to be able to get programatically get a list of tables in the database and the number of records in them and display them like this:

Table                    Number of Records
--------------------------------------------
TableOne               123
TableTwo               2121
TableThree            21212

etc


All MySQL keeps pointing me too is SHOW TABLES command in the MYSQL Consol.

What's the Java Equivalent?


0
Comment
Question by:zaphod_beeblebrox
2 Comments
 
LVL 4

Accepted Solution

by:
gdrnec earned 200 total points
ID: 12225611
You need the

ResultSet DatabaseMetaData.getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)

method from java.sql. You can pick up a reference to the DatabaseMetaData object from your Connection object.
If you don't know the arguments, don't worry, just use null and they will not be used to narrow the search.

Geoff
 
0
 

Author Comment

by:zaphod_beeblebrox
ID: 12235406
Thanks Geoff

This put me the right direction.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question