public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern,
      String[] types)
      throws SQLException {

    StringBuilder sql =
        new StringBuilder("SELECT TABLE_SCHEMA TABLE_CAT, NULL  TABLE_SCHEM,  TABLE_NAME,"
            + " IF(TABLE_TYPE='BASE TABLE', 'TABLE', TABLE_TYPE) as TABLE_TYPE,"
            + " TABLE_COMMENT REMARKS, NULL TYPE_CAT, NULL TYPE_SCHEM, NULL TYPE_NAME, NULL SELF_REFERENCING_COL_NAME, "
            + " NULL REF_GENERATION"
            + " FROM INFORMATION_SCHEMA.TABLES "
            + " WHERE "
            + catalogCond("TABLE_SCHEMA", catalog)
            + " AND "
            + patternCond("TABLE_NAME", tableNamePattern));

    if (types != null && types.length > 0) {
      sql.append(" AND TABLE_TYPE IN (");
      for (int i = 0; i < types.length; i++) {
        if (types[i] == null) {
          continue;
        }
        String type = escapeQuote(mapTableTypes(types[i]));
        if (i == types.length - 1) {
          sql.append(type).append(")");
        } else {
          sql.append(type).append(",");
        }
      }
    }

    sql.append(" ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME");

    return executeQuery(sql.toString());
  }
public ResultSet getTables ( String catalog , String schemaPattern , String tableNamePattern , String [ ] types ) throws SQLException { StringBuilder sql = new StringBuilder ( "SELECT TABLE_SCHEMA TABLE_CAT, NULL  TABLE_SCHEM,  TABLE_NAME," + " IF(TABLE_TYPE='BASE TABLE', 'TABLE', TABLE_TYPE) as TABLE_TYPE," + " TABLE_COMMENT REMARKS, NULL TYPE_CAT, NULL TYPE_SCHEM, NULL TYPE_NAME, NULL SELF_REFERENCING_COL_NAME, " + " NULL REF_GENERATION" + " FROM INFORMATION_SCHEMA.TABLES " + " WHERE " + catalogCond ( "TABLE_SCHEMA" , catalog ) + " AND " + patternCond ( "TABLE_NAME" , tableNamePattern ) ) ; if ( types != null && types . length > 0 ) { sql . append ( " AND TABLE_TYPE IN (" ) ; for ( int i = 0 ; i < types . length ; i ++ ) { if ( types [ i ] == null ) { continue ; } String type = escapeQuote ( mapTableTypes ( types [ i ] ) ) ; if ( i == types . length - 1 ) { sql . append ( type ) . append ( ")" ) ; } else { sql . append ( type ) . append ( "," ) ; } } } sql . append ( " ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME" ) ; return executeQuery ( sql . toString ( ) ) ; }
Retrieves a description of the tables available in the given catalog. Only table descriptions
matching the catalog, schema, table name and type criteria are returned.  They are ordered by
<code>TABLE_TYPE</code>, <code>TABLE_CAT</code>, <code>TABLE_SCHEM</code> and
<code>TABLE_NAME</code>.
Each table description has the following columns:
<OL> <LI><B>TABLE_CAT</B> String {@code =>}
table catalog (may be <code>null</code>)
<LI><B>TABLE_SCHEM</B> String {@code =>} table schema (may be <code>null</code>)
<LI><B>TABLE_NAME</B> String {@code =>} table name
<LI><B>TABLE_TYPE</B> String {@code =>} table type.  Typical types are "TABLE", "VIEW",
"SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". <LI><B>REMARKS</B>
String {@code =>} explanatory comment on the table
<LI><B>TYPE_CAT</B> String {@code =>} the types catalog (may be <code>null</code>)
<LI><B>TYPE_SCHEM</B> String {@code =>} the types schema (may be <code>null</code>)
<LI><B>TYPE_NAME</B> String {@code =>} type name (may be <code>null</code>)
<LI><B>SELF_REFERENCING_COL_NAME</B> String {@code =>} name of the designated "identifier"
column of a typed table (may be <code>null</code>) <LI><B>REF_GENERATION</B> String {@code =>}
specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER",
"DERIVED". (may be <code>null</code>) </OL>

<P><B>Note:</B> Some databases may not return information for all tables.</p>

@param catalog          a catalog name; must match the catalog name as it is stored in the
database; "" retrieves those without a catalog;
<code>null</code> means that the catalog name should not be used to
narrow the search
@param schemaPattern    a schema name pattern; must match the schema name as it is stored in
the database; "" retrieves those without a schema;
<code>null</code> means that the schema name should not be used to
narrow the search
@param tableNamePattern a table name pattern; must match the table name as it is stored in the
database
@param types            a list of table types, which must be from the list of table types
returned from {@link #getTableTypes},to include;
<code>null</code> returns all types
@return <code>ResultSet</code> - each row is a table description
@throws SQLException if a database access error occurs
@see #getSearchStringEscape