Solved

Java: MySQL getting tables and information within Java Code

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

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

679 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