Can't retrieve comments for indexes when using SchemaCrawler and MySQL5.7

心已入冬 提交于 2020-01-07 05:53:05

问题


I can retrieve comments for tables and columns by using SchemaCrawler and MySQL5.7, but it failed for the indexes' comments. This is an example:

1) Table definition

create table testtable(
  id bigint unsigned auto_increment,
  city_id varchar(256),
  person_id varchar(256),
  primary key(id) comment 'This is comment for the primary key',
  key idx1 (city_id, person_id) comment 'This is the comment for test index'
) comment='This is the comment for test table';

2) Java code

// jdbc:mysql://localhost:3306/testdb?useInformationSchema=true&useUnicode=true&characterEncoding=utf8
final Connection connection = ...;
final DatabaseSpecificOverrideOptions databaseSpecificOverrideOptions =
                        SchemaCrawlerUtility.matchDatabaseSpecificOverrideOptions(connection);

final SchemaCrawler schemaCrawler = new SchemaCrawler(connection, databaseSpecificOverrideOptions);

final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.maximum());
options.setTableInclusionRule(new IncludeAll());
options.setColumnInclusionRule(new IncludeAll());

final Catalog catalog = schemaCrawler.crawl(options);
final Collection<schemacrawler.schema.Table> tables = catalog.getTables();

for (schemacrawler.schema.Table t : tables) {
    System.out.println(t.getPrimaryKey().getRemarks());
    for (schemacrawler.schema.Index index : t.getIndexes()) {
        System.out.println(index.getRemarks());
    }
}

Is there anything that I should adjust ?

Thanks!


回答1:


Sorry, index comments are not supported for MySQL in SchemaCrawler 14.16.01. Please make sure that you include the us.fatehi:schemacrawler-mysql jar file on your classpath.

Sualeh Fatehi, SchemaCrawler



来源:https://stackoverflow.com/questions/43220025/cant-retrieve-comments-for-indexes-when-using-schemacrawler-and-mysql5-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!