【问题标题】:Is SchemaCrawler broken when using its API?SchemaCrawler 在使用其 API 时是否损坏?
【发布时间】:2017-04-01 11:50:06
【问题描述】:

我正在参考http://sualeh.github.io/SchemaCrawler/how-to.html#api 中的文档 但我永远得不到我想要的。返回的表始终为空。

final Connection connection = ... // Get a MYSQL connection;
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.maximum());
options.setTableInclusionRule(new IncludeAll());
options.setTableNamePattern("*");

final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection, options);

for (final Schema schema: catalog.getSchemas())
{
    Collection<Table> tables = catalog.getTables(schema);
    // 
    // The size of tables is always 0
    // 
    System.out.println(tables);
}

【问题讨论】:

  • MySQL 没有模式,只有目录(在 JDBC 术语中)。你应该使用getCatalogs() 而不是getSchemas()

标签: mysql jdbc schemacrawler


【解决方案1】:

您不应该设置表名模式,因此请删除以下行: options.setTableNamePattern("*");

Sualeh Fatehi,SchemaCrawler

【讨论】:

  • 感谢 Sualeh,这真的很有帮助
猜你喜欢
  • 1970-01-01
  • 2019-09-15
  • 1970-01-01
  • 2021-11-28
  • 2012-04-13
  • 2020-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多