【问题标题】:SchemaSpy DB2 Connection FailureSchemaSpy DB2 连接失败
【发布时间】:2018-10-10 13:48:59
【问题描述】:

我尝试使用 SchemaSpy 分析 DB2 数据库,但收到警告“连接失败”。我试过这样:

java -jar schemaspy-6.0.0.jar -configFile schemaspy.properties --logging.pattern.console="%d{HH:mm:ss.SSS} %clr(%-5level) - %msg%n" --logging.level.org.schemaspy=TRACE

(在https://github.com/schemaspy/schemaspy/issues/250上找到了日志部分)

.properties 文件如下所示:

schemaspy.t=db2
schemaspy.dp=C:\tmp\db2jcc.jar
schemaspy.host=**host**
schemaspy.port=50000
schemaspy.db=**db**
schemaspy.u=**user**
schemaspy.p=**password**
schemaspy.o=D:\**\schemaspy-output\
schemaspy.s=**schema**

我得到的错误是:

    14:24:20.297 DEBUG - Unable to find driverClass COM.ibm.db2.jdbc.app.DB2Driver'
    14:24:20.308 WARN  - Connection Failure
    org.schemaspy.model.ConnectionFailure: Failed to connect to database URL [jdbc:db2:zumtest] Failed to create any of 'COM.ibm.db2.jdbc.app.DB2Driver' driver from driverPath 'C:\tmp\db2jcc.jar' with sibling jars no.
    Resulting in classpath:
            file:/C:/tmp/db2jcc.jar

            at org.schemaspy.DbDriverLoader.getConnection(DbDriverLoader.java:101)
            at org.schemaspy.DbDriverLoader.getConnection(DbDriverLoader.java:75)
            at org.schemaspy.service.SqlService.connect(SqlService.java:68)
            at org.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:186)
            at org.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:107)
            at org.schemaspy.cli.SchemaSpyRunner.runAnalyzer(SchemaSpyRunner.java:97)
            at org.schemaspy.cli.SchemaSpyRunner.run(SchemaSpyRunner.java:86)
            at org.schemaspy.Main.main(Main.java:48)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
            at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
            at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
            at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
    Caused by: org.schemaspy.model.ConnectionFailure: Failed to create any of 'COM.ibm.db2.jdbc.app.DB2Driver' driver from driverPath 'C:\tmp\db2jcc.jar' with sibling jars no.
    Resulting in classpath:
            file:/C:/tmp/db2jcc.jar

            at org.schemaspy.DbDriverLoader.getDriver(DbDriverLoader.java:147)
            at org.schemaspy.DbDriverLoader.getConnection(DbDriverLoader.java:93)
            ... 15 common frames omitted

我猜,错误来自错误的类路径?但是我该如何解决这个问题?我试图更改 db2.properties 中的行

driver=COM.ibm.db2.jdbc.app.DB2Driver

driver=COM.ibm.db2.jcc.DB2Driver

,因为我从驱动的.jar文件中提取了这个类路径,但是没有用。

【问题讨论】:

  • JCC 驱动程序的正确类名是com.ibm.db2.jcc.DB2Driver -- 类名区分大小写。
  • 根据您的应用程序尝试使用的 url 格式 (jdbc:db2:database),它会尝试使用旧的类型 2 驱动程序 COM.ibm.db2.jdbc.app.DB2Driver,它位于db2java.zip,而不是 db2jcc*.jar。如果你想使用type 4驱动和url格式为jdbc:db2://host:port/database,你必须使用db2jcc*.jar和com.ibm.db2.jcc.DB2Driver驱动。
  • 我成功使用了这个:
  • 我将 schemaspy.properties 文件修改为 schemaspy.dp=C:\Program Files\IBM\SQLLIB\java\db2java.zip 并将 db2.properties 文件修改为 driver=COM.ibm.db2.jdbc.app.DB2DriverdriverPath=C:\Program Files\IBM\SQLLIB\java\db2java.zip schemaSpy 调用的命令行必须更改为 java -jar schemaspy-6.0.0.jar -configFile schemaspy.properties -cat % 非常感谢求助。 J.

标签: db2 schemaspy


【解决方案1】:

这对我使用 db2jcc.jar 有效

# type of database. Run with -dbhelp for details
schemaspy.t=db2
# optional path to alternative jdbc drivers.
schemaspy.dp=/lib/db2jcc.jar
# database properties: host, port number, name user, password
schemaspy.host=xxxxxx
schemaspy.port=xxxxx
schemaspy.db=xxx
schemaspy.u=xx
schemaspy.p=xx
# output dir to save generated files
schemaspy.o=/output
# db scheme for which generate diagrams
schemaspy.s=xxxx
driver=com.ibm.db2.jcc.DB2Driver
connectionSpec=jdbc:db2://xxx.xx.x.xxx:[PORT]/[DBNAME]
schemaspy.cat=%

使用的命令:

java -jar schemaspy-6.1.0.jar -configFile db2.properties  --logging.pattern.console="%d{HH:mm:ss.SSS} %clr(%-5level) - %msg%n" --logging.level.org.schemaspy=TRACE

【讨论】:

    猜你喜欢
    • 2019-01-14
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    • 2019-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多