gpt4 book ai didi

java - H2 DB 运行脚本错误

转载 作者:行者123 更新时间:2023-12-03 01:41:47 25 4
gpt4 key购买 nike

我在 H2 数据源配置中有以下行:

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:mem:test_db;INIT=CREATE SCHEMA IF NOT EXISTS test_db;\\;RUNSCRIPT FROM '~/sql/populate.sql'\\;DB_CLOSE_DELAY=-1" />
</bean>

当我运行它时,出现以下错误:

SQL state [90046];error code [90046]; URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]"
but is "jdbc:h2:mem:test_db" [90046-160]; nested exception is org.h2.jdbc
.JdbcSQLException: URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]
fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" b
ut is "jdbc:h2:mem:test_db" [90046-160]

我不明白,有人可以看到这里的错误吗?

最佳答案

尝试:

<property name="url" value="jdbc:h2:mem:test_db;INIT=CREATE SCHEMA IF NOT EXISTS test_db\;RUNSCRIPT FROM '~/sql/populate.sql';DB_CLOSE_DELAY=-1" />

关于java - H2 DB 运行脚本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8237767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com