Export (0) Print
Expand All
Expand Minimize

getTableTypes Method (SQLServerDatabaseMetaData)

Retrieves the table types that are available in the current database.


public java.sql.ResultSet getTableTypes()

This getTableTypes method is specified by the getTableTypes method in the java.sql.DatabaseMetaData interface.

The result set returned by the getTableTypes method will contain the following information:

Name

Type

Description

TABLE_TYPE

String

The table type.

NoteNote

For more information about the data returned by the getTableTypes method, see "sp_tables (Transact-SQL)" in SQL Server Books Online.

The following example demonstrates how to use the getTableTypes method to return the table type information in the SQL Server 2005 AdventureWorks sample database, given that the database is specified in the connection String.

public static void executeGetTableTypes(Connection con) {
   try {
      DatabaseMetaData dbmd = con.getMetaData();
      ResultSet rs = dbmd.getTableTypes();
      ResultSetMetaData rsmd = rs.getMetaData();

      // Display the result set data.
      int cols = rsmd.getColumnCount();
      while(rs.next()) {
         for (int i = 1; i <= cols; i++) {
            System.out.println(rs.getString(i));
         }
      }
      rs.close();
   } 

   catch (Exception e) {
      e.printStackTrace();
   }
}
Show:
© 2014 Microsoft