Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java: MySQL getting tables and information within Java Code

Posted on 2004-10-05
2
Medium Priority
?
206 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

722 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