如何使用模式爬虫与数据库建立连接并获取结果?

How do I use schema crawler to establish a connection with the database and get the result?

我在我的项目中使用这个 Gradle 依赖项

implementation group: 'us.fatehi', name: 'schemacrawler', version: '16.16.14'

项目使用 Scala 语言,DB2 是使用的数据库。

这是我使用的 scala 代码的一部分:

val limitOptionsBuilder = LimitOptionsBuilder.builder
           .includeSchemas(new RegularExpressionInclusionRule("schema_name"))
           .includeTables((tableName: String) => !tableName.contains("table_name_thats_in_the_above_scema"))

val loadOptionsBuilder = LoadOptionsBuilder.builder.withSchemaInfoLevel(SchemaInfoLevelBuilder.standard())

val options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions
                  .withLimitOptions(limitOptionsBuilder.toOptions())
                  .withLoadOptions(loadOptionsBuilder.toOptions())


var catalog :Catalog = null
catalog = SchemaCrawlerUtility.getCatalog(connection, options)

我得到以下异常:

SchemaCrawler database plugin should be on the CLASSPATH for <my_db2_classpath>,
or "SC_WITHOUT_DATABASE_PLUGIN" should be set to the name of the missing plugin
either as an environmental variable or as a Java system property

在使用 Schemacrawler 连接到数据库之前,我还需要做任何其他设置吗? 理想情况下,我需要连接到数据库并以 HTML/PDF 格式的 ER 图形式获取表之间的关系。

请添加对

的依赖

group: 'us.fatehi', name: 'schemacrawler-db2', version: '16.16.14'

Sualeh Fatehi,SchemaCrawler