Compartir a través de


getSchemas Method (SQLServerDatabaseMetaData)

Retrieves the schema names that are available in the current database.

public java.sql.ResultSet getSchemas()

Valor devuelto

A SQLServerResultSet object.

Excepciones

SQLServerException

Notas

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

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

Name Type Description

TABLE_SCHEM

String

The name of the schema.

TABLE_CATALOG

String

The catalog name for the schema.

Nota

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

Ejemplo

The following example demonstrates how to use the getSchemas method to return information about the catalog and its associated schema names in SQL Server 2005, given that the connection argument specifies the database to be used.

public static void executeGetSchemas(Connection con) {
   try {
      DatabaseMetaData dbmd = con.getMetaData();
      ResultSet rs = dbmd.getSchemas();
      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();
   }
}

Vea también

Referencia

SQLServerDatabaseMetaData Class

Conceptos

SQLServerDatabaseMetaData Methods
SQLServerDatabaseMetaData Members