Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getting all table names from mySQL database

800455Mar 13 2008 — edited Mar 14 2008
after digging around a bit i found out i could obtain the list of table names
like this
ResultSetMetaData rsMeta = tableSet.getMetaData();
        if (tableSet==null) {
          System.out.println("NO DATA IN RESULT SET");
        } else {
          System.out.println("INSIDE ELSE");
          tableSet.beforeFirst();
          System.out.println("TABLESET BEFORE FIRST");
          while (tableSet.next()) {
          // Get the table name
          System.out.println("READING COL 3");
          String tableName = tableSet.getString(3);
          System.out.println("READ COL 3");
          // Get the table's catalog and schema names (if any)
          String tableCatalog = tableSet.getString(1);
          String tableSchema = tableSet.getString(2);
          
          System.out.print("TABLE NAME: "+tableName);
          System.out.print(" TABLE CATALOG NAME: "+tableCatalog);
          System.out.println("TABLE SCHEMA NAME: "+tableSchema);
        }
          System.out.println("FINISHED");
      }
However, the code is not stepping in to print the table names. Dont know why??//
this is an example of the output
 [java] Driver :com.mysql.jdbc.Driver
 [java] URL :jdbc:mysql://localhost:3306/webmaster
 [java] Username :farouk
 [java] Password :akinom
 [java]
 [java] CrsCodeGenerator for Database JavaBean Generator v1.0
 [java] -----------------------------------------
 [java] Database version : 5.0.45-community-nt
 [java] Driver Name : MySQL-AB JDBC Driver
 [java] Driver Version : 5.1
 [java] Row Count: 5
 [java] INSIDE ELSE
 [java] TABLESET BEFORE FIRST
 [java] FINISHED
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2008
Added on Mar 13 2008
7 comments
756 views