【问题标题】:Hibernate H2 database relative pathHibernate H2 数据库相对路径
【发布时间】:2016-03-24 18:48:09
【问题描述】:

我有一个名为“test.db”的 H2 数据库文件。该文件位于我的应用程序中 目录:“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>


        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.H2Dialect</property>

发生的错误是:

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]

【问题讨论】:

    标签: java hibernate h2


    【解决方案1】:

    您应该将 URL 写为显式的相对路径: &lt;property name="connection.url"&gt;jdbc:h2:file:./test&lt;/property&gt;

    【讨论】:

      猜你喜欢
      • 2011-04-23
      • 1970-01-01
      • 2018-11-29
      • 2018-05-01
      • 2015-10-15
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 2016-05-29
      相关资源
      最近更新 更多