Class JDBCUtil


  • public final class JDBCUtil
    extends Object
    • Method Detail

      • getSingleDatabaseConfigFromEnv

        public static DatabaseConnectionConfig getSingleDatabaseConfigFromEnv​(String databaseEngine,
                                                                              Map<String,​String> configOptions)
        Extracts default database configuration for a database. Used when a specific database instance handler is used by Lambda function.
        Parameters:
        databaseEngine - database type.
        Returns:
        database connection confuiguration. See DatabaseConnectionConfig.
      • createJdbcMetadataHandlerMap

        public static Map<String,​JdbcMetadataHandler> createJdbcMetadataHandlerMap​(Map<String,​String> configOptions,
                                                                                         JdbcMetadataHandlerFactory metadataHandlerFactory)
        Creates a map of Catalog to respective metadata handler to be used by Multiplexer.
        Parameters:
        configOptions - system configOptions.
        metadataHandlerFactory - factory for creating the appropriate metadata handler for the database type
        Returns:
        Map of String -> JdbcMetadataHandler
      • getTableMetadata

        public static List<TableName> getTableMetadata​(PreparedStatement preparedStatement,
                                                       String tableType)
                                                throws SQLException
        Lists tables/views for the given prepared statement.

        A SQLException here means the data source could not be queried, which is not the same thing as a schema that legitimately holds no tables. Both used to be reported as an empty list, so a broken session (for example a Snowflake session with no active warehouse) surfaced to the customer as an empty schema and a successful request. The exception is propagated so the caller can fail the request instead.

        Throws:
        SQLException - if the table listing could not be retrieved.