MetadataResultSet(final Query query, final Statement statement, final InclusionRule schemaInclusionRule) throws SQLException { this(executeAgainstSchema(query, statement, schemaInclusionRule)); if (query.hasName()) { description = query.getName(); } }
@Test public void executeForScalar(final TestContext testContext, final Connection cxn) throws Exception { final Query query = new Query("Select scalar", "SELECT POSTALCODE FROM PUBLIC.BOOKS.AUTHORS WHERE LASTNAME = 'Shaffer'"); final Object scalar = QueryUtility.executeForScalar(query, cxn); assertThat(scalar, notNullValue()); assertThat(scalar, is("37032")); }
tableProperties.put("tablename", table.getName()); tableProperties.put("columns", getColumnsListAsString(columns, false, identifiers)); tableProperties.put("orderbycolumns", getColumnsListAsString(columns, true, identifiers)); tableProperties.put("tabletype", table.getTableType().toString());
public static Object executeForScalar(final Query query, final Connection connection) throws SchemaCrawlerException { requireNonNull(query, "No query provided"); final String sql = getQuery(query); LOGGER.log(Level.FINE, new StringFormat("Executing %s: %n%s", query.getName(), sql)); return executeSqlForScalar(connection, sql); }
final long count = executeForLong(query, connection, table,
.isAlphabeticalSortForTableColumns(); try ( final ResultSet results = executeAgainstTable(query, statement, table,
public static ResultSet executeAgainstSchema(final Query query, final Statement statement, final InclusionRule schemaInclusionRule) throws SQLException { requireNonNull(query, "No query provided"); final String sql = getQuery(query, schemaInclusionRule); LOGGER.log(Level.FINE, new StringFormat("Executing %s: %n%s", query.getName(), sql)); return executeSql(statement, sql); }
final long count = executeForLong(query, connection, table,
.isAlphabeticalSortForTableColumns(); try ( final ResultSet results = executeAgainstTable(query, statement, table,
public static long executeForLong(final Query query, final Connection connection, final Table table, final Identifiers identifiers) throws SchemaCrawlerException { requireNonNull(query, "No query provided"); final String sql = getQuery(query, table, true, identifiers); LOGGER.log(Level.FINE, new StringFormat("Executing %s: %n%s", query.getName(), sql)); return executeSqlForLong(connection, sql); }
MetadataResultSet(final Query query, final Statement statement, final InclusionRule schemaInclusionRule) throws SQLException { this(executeAgainstSchema(query, statement, schemaInclusionRule)); if (query.hasName()) { description = query.getName(); } }
@Test public void executeForScalarNotPresent(final TestContext testContext, final Connection cxn) throws Exception { final Query query = new Query("Select scalar", "SELECT POSTALCODE FROM PUBLIC.BOOKS.AUTHORS WHERE LASTNAME = 'Fatehi'"); final Object scalar = QueryUtility.executeForScalar(query, cxn); assertThat(scalar, nullValue()); }
tableProperties.put("tablename", table.getName()); tableProperties.put("columns", getColumnsListAsString(columns, false, identifiers)); tableProperties.put("orderbycolumns", getColumnsListAsString(columns, true, identifiers)); tableProperties.put("tabletype", table.getTableType().toString());
final long count = executeForLong(query, connection, table,
.isAlphabeticalSortForTableColumns(); try ( final ResultSet results = executeAgainstTable(query, statement, table,
public static Object executeForScalar(final Query query, final Connection connection, final Table table, final Identifiers identifiers) throws SchemaCrawlerException { requireNonNull(query, "No query provided"); final String sql = getQuery(query, table, true, identifiers); LOGGER.log(Level.FINE, new StringFormat("Executing %s: %n%s", query.getName(), sql)); return executeSqlForScalar(connection, sql); }
@Test public void executeAgainstSchemaNoMatch(final TestContext testContext, final Connection cxn) throws Exception { final Query query = new Query("Tables for schema", "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE REGEXP_MATCHES(TABLE_SCHEMA, '${schemas}') ORDER BY TABLE_NAME"); final InclusionRule schemaInclusionRule = new RegularExpressionInclusionRule("NONE"); int rows = 0; try (final Connection connection = cxn; final Statement statement = connection.createStatement(); final ResultSet resultSet = QueryUtility .executeAgainstSchema(query, statement, schemaInclusionRule);) { while (resultSet.next()) { rows++; } } assertThat(rows, is(0)); }
private String getCatalogScope(final Connection connection) { String catalogScope = "ALL"; try { final Query query = new Query("Check access to DBA tables", "SELECT TABLE_NAME FROM DBA_TABLES WHERE ROWNUM = 1"); final Object scalar = executeForScalar(query, connection); if (scalar != null) { catalogScope = "DBA"; } } catch (final SchemaCrawlerException e) { LOGGER.log(Level.FINE, e.getMessage(), e); catalogScope = "ALL"; } LOGGER .log(Level.INFO, new StringFormat("Using Oracle data dictionary catalog scope <%s>", catalogScope)); return catalogScope; }
tableProperties.put("tablename", table.getName()); tableProperties.put("columns", getColumnsListAsString(columns, false, identifiers)); tableProperties.put("orderbycolumns", getColumnsListAsString(columns, true, identifiers)); tableProperties.put("tabletype", table.getTableType().toString());
public static ResultSet executeAgainstSchema(final Query query, final Statement statement, final InclusionRule schemaInclusionRule) throws SQLException { requireNonNull(query, "No query provided"); final String sql = getQuery(query, schemaInclusionRule); LOGGER.log(Level.FINE, new StringFormat("Executing %s: %n%s", query.getName(), sql)); return executeSql(statement, sql); }