mysqljdbcschemacrawler

Is SchemaCrawler broken when using its API?


I am refering the doc in http://sualeh.github.io/SchemaCrawler/how-to.html#api But I never get what I want. The tables returned is always empty.

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

Solution

  • You should not set the table name pattern, so please remove the following line: options.setTableNamePattern("*");

    Sualeh Fatehi, SchemaCrawler