public static Connection checkConnection(final Connection connection) throws SchemaCrawlerSQLException { try { requireNonNull(connection, "No connection provided"); if (connection.isClosed()) { throw new SQLException("Connection is closed"); } } catch (final NullPointerException | SQLException e) { throw new SchemaCrawlerSQLException("Bad database connection", e); } return connection; }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
public static Connection checkConnection(final Connection connection) throws SchemaCrawlerSQLException { try { requireNonNull(connection, "No connection provided"); if (connection.isClosed()) { throw new SQLException("Connection is closed"); } } catch (final NullPointerException | SQLException e) { throw new SchemaCrawlerSQLException("Bad database connection", e); } return connection; }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
public static ResultSet checkResultSet(final ResultSet resultSet) throws SchemaCrawlerSQLException { try { requireNonNull(resultSet, "No result-set provided"); if (resultSet.isClosed()) { throw new SQLException("Result-set is closed"); } } catch (final NullPointerException | SQLException e) { throw new SchemaCrawlerSQLException("Bad result-set", e); } return resultSet; }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
public static ResultSet checkResultSet(final ResultSet resultSet) throws SchemaCrawlerSQLException { try { requireNonNull(resultSet, "No result-set provided"); if (resultSet.isClosed()) { throw new SQLException("Result-set is closed"); } } catch (final NullPointerException | SQLException e) { throw new SchemaCrawlerSQLException("Bad result-set", e); } return resultSet; }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
private final Driver getJdbcDriver(final String connectionUrl) throws SQLException { try { return DriverManager.getDriver(connectionUrl); } catch (final SQLException e) { throw new SchemaCrawlerSQLException("Could not find a suitable JDBC driver for database connection URL, " + getConnectionUrl(), e); } }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
private void retrievePrimaryKeysFromMetadataForAllTables(final NamedObjectList<MutableTable> allTables) throws SQLException { try (final MetadataResultSet results = new MetadataResultSet(getMetaData() .getPrimaryKeys(null, null, "%"));) { while (results.next()) { final Optional<MutableTable> optionalTable = lookupTable(allTables, results); if (!optionalTable.isPresent()) { continue; } final MutableTable table = optionalTable.get(); createPrimaryKeyForTable(table, results); } } catch (final SQLException e) { throw new SchemaCrawlerSQLException("Could not retrieve primary keys for tables", e); } }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
private void retrievePrimaryKeysFromMetadataForAllTables(final NamedObjectList<MutableTable> allTables) throws SQLException { try (final MetadataResultSet results = new MetadataResultSet(getMetaData() .getPrimaryKeys(null, null, "%"));) { while (results.next()) { final Optional<MutableTable> optionalTable = lookupTable(allTables, results); if (!optionalTable.isPresent()) { continue; } final MutableTable table = optionalTable.get(); createPrimaryKeyForTable(table, results); } } catch (final SQLException e) { throw new SchemaCrawlerSQLException("Could not retrieve primary keys for tables", e); } }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
private void retrieveIndexesFromMetadataForAllTables(final NamedObjectList<MutableTable> allTables, final boolean unique) throws SQLException { try (final MetadataResultSet results = new MetadataResultSet(getMetaData() .getIndexInfo(null, null, "%", unique, true/* approximate */));) { while (results.next()) { final Optional<MutableTable> optionalTable = lookupTable(allTables, results); if (!optionalTable.isPresent()) { continue; } final MutableTable table = optionalTable.get(); createIndexForTable(table, results); } } catch (final SQLException e) { throw new SchemaCrawlerSQLException("Could not retrieve indexes for tables", e); } }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
private void retrieveIndexesFromMetadataForAllTables(final NamedObjectList<MutableTable> allTables, final boolean unique) throws SQLException { try (final MetadataResultSet results = new MetadataResultSet(getMetaData() .getIndexInfo(null, null, "%", unique, true/* approximate */));) { while (results.next()) { final Optional<MutableTable> optionalTable = lookupTable(allTables, results); if (!optionalTable.isPresent()) { continue; } final MutableTable table = optionalTable.get(); createIndexForTable(table, results); } } catch (final SQLException e) { throw new SchemaCrawlerSQLException("Could not retrieve indexes for tables", e); } }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());
private void retrieveIndexesFromMetadata(final MutableTable table, final boolean unique) throws SQLException { try (final MetadataResultSet results = new MetadataResultSet(getMetaData() .getIndexInfo(table.getSchema().getCatalogName(), table.getSchema().getName(), table.getName(), unique, true/* approximate */));) { createIndexes(table, results); } catch (final SQLException e) { throw new SchemaCrawlerSQLException("Could not retrieve indexes for table " + table, e); } }
throw new SchemaCrawlerException(e.getMessage(), e.getCause());