【发布时间】:2022-08-14 09:54:25
【问题描述】:
我正在尝试以服务器模式启动 H2 以连接另一台计算机上的应用程序。但无论我多么努力,我都没有成功。
我已经看过文档并从命令行启动服务器执行:
java -cp h2-2.1.214.jar org.h2.tools.Server -tcpAllowOthers
输出:
TCP server running at tcp://127.0.1.1:9092 (others can connect)
PG server running at pg://127.0.1.1:5435 (only local connections)
Web Console server running at https://127.0.1.1:8082 (others can connect)
现在从另一台电脑上,据我了解,我必须按以下方式执行连接:
jdbc:h2:tcp://[server][:port]/[path]/[databaseName]
那么它应该是:
jdbc:h2:tcp://127.0.1.1:9092/home/mateo/database
但我读过 127.0.1.1 只能在本地工作。我也注意到,在我看到的例子中打开H2 Console时,出现了机器的ip,即:192.168.X。
我究竟做错了什么?
(更新)
我目前正在使用 Linux。 我已经从 Windows 启动了服务器,并按照上述步骤成功地从 Linux 连接了它。但是,我仍然不明白为什么它在 Linux 中不起作用,在 Windows 中它会使用机器的 IP 地址加载服务器。这让我觉得我必须为 Linux 做一些额外的配置。