class PostgreSQLDataSourceChecker extends AbstractDataSourceChecker {

    @Override
    public void checkPrivilege(final Collection<? extends DataSource> dataSources) {
        try {
            for (DataSource dataSource : dataSources) {
                String tableName;
                try (Connection connection = dataSource.getConnection()) {
                    ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), null, "%", new String[]{"TABLE"});
                    if (tables.next()) {
                        tableName = tables.getString(3);
                    } else {
                        throw new PrepareFailedException("No tables find in the source data source");
                    }
                    connection.prepareStatement(String.format("SELECT * FROM %s LIMIT 1", tableName)).executeQuery();
                }
            }
        } catch (final SQLException ex) {
            throw new PrepareFailedException("Data sources privilege check failed!", ex);
        }
    }

}