/** * Gets the additional attributes SQL for columns, from the additional * configuration. * * @return Additional attributes SQL for columns. */ public Query getQuery(final InformationSchemaKey key) { requireNonNull(key, "No SQL query key provided"); return new Query(key.name(), informationSchemaQueries.get(key)); }
/** * {@inheritDoc} */ @Override public void handleData(final Query query, final ResultSet rows) throws SchemaCrawlerException { String title; if (query != null) { title = query.getName(); } else { title = ""; } handleData(title, rows); }
private static String getQuery(final Query query) { return expandTemplate(query.getQuery()); }
handler.handleInfoEnd(); if (query.isQueryOver()) final String sql = query.getQuery(); try (final ResultSet results = executeSql(statement, sql, true);)
handler.handleInfoEnd(); if (query.isQueryOver()) final String sql = query.getQuery(); try (final ResultSet results = executeSql(statement, sql, true);)
/** * Gets the additional attributes SQL for columns, from the additional * configuration. * * @return Additional attributes SQL for columns. */ public Query getQuery(final InformationSchemaKey key) { requireNonNull(key, "No SQL query key provided"); return new Query(key.name(), informationSchemaQueries.get(key)); }
/** * {@inheritDoc} */ @Override public void handleData(final Query query, final ResultSet rows) throws SchemaCrawlerException { String title; if (query != null) { title = query.getName(); } else { title = ""; } handleData(title, rows); }
private static String getQuery(final Query query) { return expandTemplate(query.getQuery()); }
handler.handleInfoEnd(); if (query.isQueryOver()) final String sql = query.getQuery(); try (final ResultSet results = executeSql(statement, sql, true);)
/** * Query. * * @return Query */ public Query getQuery() { return new Query(name(), queryString); }
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); }
/** * Gets the query with parameters substituted. * * @param schemaInclusionRule * Schema inclusion rule * @return Ready-to-execute query */ private static String getQuery(final Query query, final InclusionRule schemaInclusionRule) { final Map<String, String> properties = new HashMap<>(); properties.put("schemas", ".*"); if (schemaInclusionRule != null && schemaInclusionRule instanceof InclusionRuleWithRegularExpression) { final String schemaInclusionPattern = ((InclusionRuleWithRegularExpression) schemaInclusionRule) .getInclusionPattern().pattern(); if (!isBlank(schemaInclusionPattern)) { properties.put("schemas", schemaInclusionPattern); } } String sql = query.getQuery(); sql = expandTemplate(sql, properties); sql = expandTemplate(sql); return sql; }
@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")); }
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); }
/** * Gets the query with parameters substituted. * * @param schemaInclusionRule * Schema inclusion rule * @return Ready-to-execute query */ private static String getQuery(final Query query, final InclusionRule schemaInclusionRule) { final Map<String, String> properties = new HashMap<>(); properties.put("schemas", ".*"); if (schemaInclusionRule != null && schemaInclusionRule instanceof InclusionRuleWithRegularExpression) { final String schemaInclusionPattern = ((InclusionRuleWithRegularExpression) schemaInclusionRule) .getInclusionPattern().pattern(); if (!isBlank(schemaInclusionPattern)) { properties.put("schemas", schemaInclusionPattern); } } String sql = query.getQuery(); sql = expandTemplate(sql, properties); sql = expandTemplate(sql); return sql; }
@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()); }