--- title: "getCatalogs Method (SQLServerDatabaseMetaData) | Microsoft Docs" ms.custom: "" ms.date: "01/19/2017" ms.prod: sql ms.prod_service: connectivity ms.reviewer: "" ms.technology: connectivity ms.topic: conceptual apiname: - "SQLServerDatabaseMetaData.getCatalogs" apilocation: - "sqljdbc.jar" apitype: "Assembly" ms.assetid: 7f8bd0f1-f340-4bb9-b559-0a6176124033 author: David-Engel ms.author: v-daenge --- # getCatalogs Method (SQLServerDatabaseMetaData) [!INCLUDE[Driver_JDBC_Download](../../../includes/driver_jdbc_download.md)] Retrieves the catalog names that are available in the connected server. ## Syntax ``` public java.sql.ResultSet getCatalogs() ``` ## Return Value A [SQLServerResultSet](../../../connect/jdbc/reference/sqlserverresultset-class.md) object. ## Exceptions [SQLServerException](../../../connect/jdbc/reference/sqlserverexception-class.md) ## Remarks This getCatalogs method is specified by the getCatalogs method in the java.sql.DatabaseMetaData interface. > [!NOTE] > On SQL Azure, you should connect to the master database to call **SQLServerDatabaseMetaData.getCatalogs**. SQL Azure does not support returning the entire set of catalogs from a user database. **SQLServerDatabaseMetaData.getCatalogs** uses the sys.databases view to get the catalogs. Please refer to the discussion of permissions in [sys.database_usage (Azure SQL Database)](../../../relational-databases/system-catalog-views/sys-database-usage-azure-sql-database.md) to understand **SQLServerDatabaseMetaData.getCatalogs** behavior on SQL Azure. The result set returned by the getCatalogs method will contain the following information: |Name|Type|Description| |----------|----------|-----------------| |TABLE_CAT|**String**|The name of the catalog, including system databases in [!INCLUDE[msCoName](../../../includes/msconame_md.md)] [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)].| ## Example The following example demonstrates how to use the getCatalogs method to return the names of all the databases that are contained in [!INCLUDE[msCoName](../../../includes/msconame_md.md)] [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)], including the system databases. ``` public static void executeGetCatalogs(Connection con) { try { DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = dbmd.getCatalogs(); 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(); } } ``` ## See Also [SQLServerDatabaseMetaData Methods](../../../connect/jdbc/reference/sqlserverdatabasemetadata-methods.md) [SQLServerDatabaseMetaData Members](../../../connect/jdbc/reference/sqlserverdatabasemetadata-members.md) [SQLServerDatabaseMetaData Class](../../../connect/jdbc/reference/sqlserverdatabasemetadata-class.md)