Solved

Java: MySQL getting tables and information within Java Code

Posted on 2004-10-05
2
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
gdrnec earned 50 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

631 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