【发布时间】: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