Reputation: 849
I have an H2 database file calls "test.db". The file is located in my application directory: "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]
Upvotes: 6
Views: 5791
Reputation: 5828
You should write the URL as a explicit relative path:
<property name="connection.url">jdbc:h2:file:./test</property>
Upvotes: 9