【问题标题】:Error when connecting H2 with symmetricDS using jdbc使用 jdbc 将 H2 与 symmetricDS 连接时出错
【发布时间】:2021-09-13 03:10:35
【问题描述】:

我试图在 虚拟机 中创建 H2 和 SymmetricDS 之间的数据库连接。按照这个教程(H2-Installation),我能够安装 H2 并使用 H2 浏览器创建 store001 H2 数据库。但是,当我连接到 SymmetricDS 时,它会在连接上引发一些错误。

对称配置:

db.driver=org.h2.Driver
db.url=jdbc:h2:~/store001;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000

H2 配置(在 h2.sh 中):

java -cp "$dir/h2-1.4.200.jar:$H2DRIVERS:$CLASSPATH" org.h2.tools.Server -web -webAllowOthers -ifNotExists "$@"

H2 浏览器(设法创建 store-001):

使用 H2 jdbc 连接运行 symmetricDS 时出错:

Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "/root/store001 outside /opt/symmetric-server-3.12.10/db/h2" [90028-176]

这些是我尝试解决此问题的步骤:

  1. 在 h2.sh 中添加 -Dh2.baseDir=/。遵循此解决方案-> solution-example

但是在运行H2时出现这个错误:

Exception in thread "main" org.h2.jdbc.JdbcSQLFeatureNotSupportedException: Feature not supported: "-Dh2.baseDir=/" [50100-200]
  1. 将 H2 浏览器从 Embedded 更改为 Server。但在浏览器中出现此错误:

Connection is broken: "java.net.ConnectException: Connection refused (Connection refused): localhost" [90067-200] 90067/90067 (Help)

我应该怎么做才能解决这个问题?

【问题讨论】:

    标签: database connection h2 symmetricds


    【解决方案1】:

    SymmetricDS 正在为 H2 使用 1.3.176 版本。

    使用 SymmetricDS 安装中的 1.3.176 H2 jar 文件: java -cp /opt/symmetric-ds/web/WEB-INF/lib/h2-1.3.176.jar::$H2DRIVERS:$CLASSPATH" org.h2.tools.Server -web -webAllowOthers -ifNotExists "$@"

    您可以在创建文件时指定 H2 URL,如下所示: jdbc:h2:/opt/symmetric-ds/tmp/h2/store001

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多