2017-04-01 33 views
0

我正在參考http://sualeh.github.io/SchemaCrawler/how-to.html#api 中的文檔但我從來沒有得到我想要的。返回的表總是空的。當使用API​​時,SchemaCrawler是否被破壞?

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

MySQL有沒有模式,只有目錄(在JDBC項)。你應該使用'getCatalogs()'而不是'getSchemas()' –

回答

1

你不應該設置表名稱模式,所以請刪除以下行: options.setTableNamePattern("*");

Sualeh Fatehi,SchemaCrawler

+0

謝謝Sualeh,這真的有幫助 – user1040933

相關問題