How do I check what table types exist in a database?

Lennart Jorelid

Use the getTableTypes method of interface java.sql.DatabaseMetaData to probe the database for table types. The exact usage is described in the code below.

public static void main(String[] args) throws Exception
      // Load the database driver - in this case, we
      // use the Jdbc/Odbc bridge driver.

      // Open a connection to the database
      Connection conn = DriverManager.getConnection("[jdbcURL]", 
                        "[login]", "[passwd]");

      // Get DatabaseMetaData
      DatabaseMetaData dbmd = conn.getMetaData();

      // Get all table types.
      ResultSet rs = dbmd.getTableTypes();

      // Printout table data
          // Printout
          System.out.println("Type: " + rs.getString(1));

      // Close database resources
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact