Solved

Java: MySQL getting tables and information within Java Code

Posted on 2004-10-05
2
198 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 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 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 covers a step-by-step guide to install VisualVM launcher in eclipse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now