我正在使用控制台
对于 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/