问题描述
我有一个H2数据库文件调用test.db。该文件位于我的应用程序
目录中:myApp / resources / test.db。
我无法得到这个作品。所以,什么是引用相对路径的正确方法。
这是我的配置hibernate.cfg.xml。
< property name =connection.driver_class> org.h2.Driver< / property> ;
< property name =connection.url> jdbc:h2:file:/ test< / property>
< property name =connection.username> test< / property>
< property name =connection.password> 1234< / property>
< property name =dialect> org.hibernate.dialect.H2Dialect< / property>
发生的错误是:
<$ p $由于:org.h2.jdbc.JdbcSQLException:数据库URLjdbc:h2:file:/ test2中不允许隐含相对于当前工作目录的文件路径。改用绝对路径,〜/ name,./name或baseDir设置。 [90011-191]
一个明确的相对路径:
< property name =connection.url> jdbc:h2:file:./ test< / property>
I have an H2 database file calls "test.db". The file is located in my applicationdirectory: "myApp/resources/test.db".I'm not able to get this works for me.So, what's the correct way to refere to a relative path.
Here is the configuration of my hibernate.cfg.xml.
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:file:/test</property>
<property name="connection.username">test</property>
<property name="connection.password">1234</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
The error occurs is:
Caused by: 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:file:/test2". Use an absolute path, ~/name, ./name, or the baseDir setting instead. [90011-191]
You should write the URL as a explicit relative path: <property name="connection.url">jdbc:h2:file:./test</property>
这篇关于休眠H2数据库相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!