schemacrawler java.lang.NullPointerException:无法检索目录

发布于 2025-01-15 01:09:33 字数 884 浏览 2 评论 0原文

我尝试将 schemacrawler 与 hsqldb 2.51 和 h2 2.x 一起使用,代码如下:

final LimitOptionsBuilder limit = LimitOptionsBuilder.builder()
    .includeSchemas(new IncludeAll())
    .includeTables(new IncludeAll());
final LoadOptionsBuilder load = LoadOptionsBuilder.builder()
    .withSchemaInfoLevel(SchemaInfoLevelBuilder.minimum());
final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions()
    .withLimitOptions(limit.toOptions())
    .withLoadOptions(load.toOptions());
final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection, options);
// throw NullPointerException
for (final schemacrawler.schema.Table t : catalog.getTables())
{
    //more code...
}

我无法在没有 NullPointerException 错误的情况下获取目录。 我的类路径中有两个档案:

  • schemacrawler-16.16.11.jar
  • schemacrawler-hsqldb-16.16.11.jar

如果有人有想法......

I try to use schemacrawler with hsqldb 2.51 and h2 2.x with the following code:

final LimitOptionsBuilder limit = LimitOptionsBuilder.builder()
    .includeSchemas(new IncludeAll())
    .includeTables(new IncludeAll());
final LoadOptionsBuilder load = LoadOptionsBuilder.builder()
    .withSchemaInfoLevel(SchemaInfoLevelBuilder.minimum());
final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions()
    .withLimitOptions(limit.toOptions())
    .withLoadOptions(load.toOptions());
final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection, options);
// throw NullPointerException
for (final schemacrawler.schema.Table t : catalog.getTables())
{
    //more code...
}

I can't get the catalog without an NullPointerException error.
I have two archives in the classpath:

  • schemacrawler-16.16.11.jar
  • schemacrawler-hsqldb-16.16.11.jar

If someone has an idea...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烛影斜 2025-01-22 01:09:33

更改一些代码后,我设法得到了一些有用的东西...

new LoggingConfig(Level.ALL);
final LimitOptionsBuilder limit = LimitOptionsBuilder.builder()
    .includeSchemas(new IncludeAll())
    .includeTables(new IncludeAll());
final LoadOptionsBuilder load = LoadOptionsBuilder.builder()
    .withSchemaInfoLevel(SchemaInfoLevelBuilder.minimum());
final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions()
    .withLimitOptions(limit.toOptions())
    .withLoadOptions(load.toOptions()); 
final SchemaRetrievalOptions retrieval = SchemaCrawlerUtility.matchSchemaRetrievalOptions(connection);
schemacrawler.crawl.SchemaCrawler crawler = new schemacrawler.crawl.SchemaCrawler(connection, retrieval, options);
final Catalog catalog = crawler.crawl();
for (final schemacrawler.schema.Table t : catalog.getTables())
    {
        //more code...
    }

但是,第一个代码总是给我同样的错误...

After changing some code I managed to have something that works...

new LoggingConfig(Level.ALL);
final LimitOptionsBuilder limit = LimitOptionsBuilder.builder()
    .includeSchemas(new IncludeAll())
    .includeTables(new IncludeAll());
final LoadOptionsBuilder load = LoadOptionsBuilder.builder()
    .withSchemaInfoLevel(SchemaInfoLevelBuilder.minimum());
final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions()
    .withLimitOptions(limit.toOptions())
    .withLoadOptions(load.toOptions()); 
final SchemaRetrievalOptions retrieval = SchemaCrawlerUtility.matchSchemaRetrievalOptions(connection);
schemacrawler.crawl.SchemaCrawler crawler = new schemacrawler.crawl.SchemaCrawler(connection, retrieval, options);
final Catalog catalog = crawler.crawl();
for (final schemacrawler.schema.Table t : catalog.getTables())
    {
        //more code...
    }

However, the first code always gives me the same error...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文