2016-03-24 21 views
2

"test.db"というH2データベースファイルがあります。ファイルは私のアプリケーション ディレクトリにあります: "myApp/resources/test.db"。 私はこれを私のために働かせることはできません。だから、相対的な経路に耳を傾ける正しい方法は何ですか。Hibernate H2データベースの相対パス

これは私の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] 

答えて

3

あなたが明示的に相対パスとしてURLを記述する必要があります。 <property name="connection.url">jdbc:h2:file:./test</property>