h2 - h2 数据库连接错误 : java. lang.NumberFormatException:零长度字符串

标签 h2

我正在使用控制台

对于 URL:jdbc:h2:tcp://localhost:/shared/test

一般错误:“java.lang.NumberFormatException:零长度字符串”[50000-180] HY000/50000(帮助)

最新版本中的 h2 url 似乎已更改。创建/shared/test 路径的正确方法是什么?

更新当尝试不带冒号的 URL 时,我们得到以下结果:

val url="jdbc:h2:tcp://localhost/shared/test;auto_server=true"

org.h2.jdbc.JdbcSQLException: A file path that is implicitly relative to the current working directory is not allowed in the database URL "jdbc:h2:tcp://localhost/shared/test;auto_server=true". Use an absolute path, ~/name, ./name, or the baseDir setting instead. [90011-180]

最佳答案

localhost 后面有一个冒号,但没有端口号。您需要使用:

jdbc:h2:tcp://localhost/shared/test

jdbc:h2:tcp://localhost:9123/shared/test

更新

下一个问题是关于数据库 URL jdbc:h2:tcp://localhost/shared/test;auto_server=true。正如异常(exception)情况所示,这是一个相对路径。您可以阅读the docs for this error message 。我认为你想要使用的是:

(Windows):

jdbc:h2:tcp://localhost/C:/shared/test;auto_server=true

或(Linux、Mac OS:根目录):

jdbc:h2:tcp://localhost//shared/test;auto_server=true

或(相对于当前用户主目录):

jdbc:h2:tcp://localhost/~/shared/test;auto_server=true

关于h2 - h2 数据库连接错误 : java. lang.NumberFormatException:零长度字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25167970/

相关文章:

java - 更新和/或删除时违反 Hibernate H2 引用完整性约束

mysql - h2 数据库 3 个表在一个查询中删除

java - H2 在 Junit 测试中未按问题检测组

java - 如何允许多个用户同时连接到我的 H2 数据库?

PHP 连接 H2DB H2 数据库

jdbc - 在 WEB-INF 目录中嵌入 H2 数据库

unit-testing - 用于测试的嵌入式 H2 数据库的 Spring 配置

java - 如何将H2数据库文件存储到项目目录中

spring - 如何使用 Spring Boot 在 H2 控制台中设置默认 JDBC URL 值

java - 使用 H2 数据库的 JDBC 中的年份从负 -509 变为正 510