schemacrawler.utility.Query类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中schemacrawler.utility.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:schemacrawler.utility.Query
类名称:Query

Query介绍

[英]A SQL query. May be parameterized with ant-like variable references.
[中]SQL查询。可以使用类似蚂蚁的变量引用进行参数化。

代码示例

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * 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));
}

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * {@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);
}

代码示例来源:origin: schemacrawler/SchemaCrawler

private static String getQuery(final Query query)
{
 return expandTemplate(query.getQuery());
}

代码示例来源:origin: schemacrawler/SchemaCrawler

MetadataResultSet(final Query query,
         final Statement statement,
         final InclusionRule schemaInclusionRule)
 throws SQLException
{
 this(executeAgainstSchema(query, statement, schemaInclusionRule));
 if (query.hasName())
 {
  description = query.getName();
 }
}

代码示例来源:origin: schemacrawler/SchemaCrawler

handler.handleInfoEnd();
if (query.isQueryOver())
 final String sql = query.getQuery();
 try (final ResultSet results = executeSql(statement, sql, true);)

代码示例来源:origin: schemacrawler/SchemaCrawler

MetadataResultSet(final Query query,
         final Statement statement,
         final InclusionRule schemaInclusionRule)
 throws SQLException
{
 this(executeAgainstSchema(query, statement, schemaInclusionRule));
 if (query.hasName())
 {
  description = query.getName();
 }
}

代码示例来源:origin: us.fatehi/schemacrawler-tools

handler.handleInfoEnd();
if (query.isQueryOver())
 final String sql = query.getQuery();
 try (final ResultSet results = executeSql(statement, sql, true);)

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * 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));
}

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * {@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);
}

代码示例来源:origin: schemacrawler/SchemaCrawler

private static String getQuery(final Query query)
{
 return expandTemplate(query.getQuery());
}

代码示例来源:origin: us.fatehi/schemacrawler

MetadataResultSet(final Query query,
         final Statement statement,
         final InclusionRule schemaInclusionRule)
 throws SQLException
{
 this(executeAgainstSchema(query, statement, schemaInclusionRule));
 if (query.hasName())
 {
  description = query.getName();
 }
}

代码示例来源:origin: us.fatehi/schemacrawler

handler.handleInfoEnd();
if (query.isQueryOver())
 final String sql = query.getQuery();
 try (final ResultSet results = executeSql(statement, sql, true);)

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * Query.
 *
 * @return Query
 */
public Query getQuery()
{
 return new Query(name(), queryString);
}

代码示例来源:origin: schemacrawler/SchemaCrawler

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);
}

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * 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;
}

代码示例来源:origin: us.fatehi/schemacrawler-api

MetadataResultSet(final Query query,
         final Statement statement,
         final InclusionRule schemaInclusionRule)
 throws SQLException
{
 this(executeAgainstSchema(query, statement, schemaInclusionRule));
 if (query.hasName())
 {
  description = query.getName();
 }
}

代码示例来源:origin: schemacrawler/SchemaCrawler

@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"));
}

代码示例来源:origin: schemacrawler/SchemaCrawler

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);
}

代码示例来源:origin: schemacrawler/SchemaCrawler

/**
 * 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;
}

代码示例来源:origin: schemacrawler/SchemaCrawler

@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());
}

相关文章

微信公众号

最新文章

更多