如何预先创建或允许H2数据库的自动摄入?

发布于 2025-01-29 15:34:34 字数 229 浏览 1 评论 0原文

我正在尝试

jdbc:h2:tcp://localhost/~/test

H2 Web接口打开测试URL,但它说

数据库“ d:/users/username/test”找不到,无论是预先创建还是 允许创建远程数据库(不建议在安全 环境)

如何实现任何一个PF命题?

I am trying to open test url

jdbc:h2:tcp://localhost/~/test

from H2 web interface, but it says

Database "D:/Users/USERNAME/test" not found, either pre-create it or
allow remote database creation (not recommended in secure
environments)

How to fulfil either pf propositions?

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

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

发布评论

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

评论(1

岁月如刀 2025-02-05 15:34:34

如果您有一个单独的H2服务器进程(从JAR文件或服务启动),则可以从系统托盘中的图标打开H2 Console 并使用JDBC:H2:〜/ Test url中,此H2控制台的副本应能够自动创建嵌入式数据库(除非启用了其他主机的远程访问)。其他Java进程仍然需要JDBC:H2:TCP:// localhost/〜/test url与该数据库的连接,他们可以在创建服务器上嵌入的数据库后使用此远程URL。

如果H2的H2控制台和TCP服务器是从您的应用程序启动的,则您的应用程序应通过与相同的嵌入式URL JDBC:H2:〜/test首先建立连接来创建此数据库。

您还可以使用Shell工具或任何其他方法来创建数据库:

”还需要在创建过程中使用JDBC:H2:〜/TEST URL。

还有一个标志可以启用远程数据库创建,但是此功能打开了一个安全孔,如果启用了本地(默认情况下远程连接,则默认情况下是禁用远程连接),如果它们明确启用了远程连接。您应该避免使用此功能。

If you have a separate H2 Server process (launched from a jar file or as a service), you can open H2 Console from its icon in the system tray and use jdbc:h2:~/test URL in it, this copy of H2 Console should be able to create embedded databases automatically (unless remote access from other hosts was enabled). Other Java processes will still need jdbc:h2:tcp://localhost/~/test URL for connections to this database and they can use this remote URL after creation of embedded database on the server.

If H2 Console and TCP Server of H2 were launched from your application, your application should create this database by itself by establishing a connection with the same embedded URL jdbc:h2:~/test first.

You can also use a shell tool or any other way to create your database:
https://h2database.com/html/tutorial.html#creating_new_databases

All these ways also require the jdbc:h2:~/test URL to be used during creation.

There is also a flag to enable remote database creation, but this feature opens a security hole, either local (if remote connections are disabled by default) or remote if they were explicitly enabled. You should avoid usage of this feature.

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