0

I am using hibernate and HSQLDB. HSQLDB works in in-process mode.

The database query:

    session.createQuery("from Doctor").list();

returns an empty list. But, in reality, the database tables are not empty and all database files are in project package

image

hibernate configuration:

<hibernate-configuration>
  <session-factory>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <!-- In-Process database connection-->
    <property name="hibernate.connection.url">jdbc:hsqldb:file:demodb;shutdown=true</property>
    <property name="hibernate.connection.username">user1</property>
    <property name="hibernate.connection.password">user1</property>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">update</property>
    <mapping class="com.mycom.entity.Doctor"></mapping>
  </session-factory>
</hibernate-configuration>

How do I solve this problem?

SternK
  • 11,649
  • 22
  • 32
  • 46
Gdd gffg
  • 13
  • 3

1 Answers1

0

Your JDBC URL opens the database in the directory where the Java VM was started. You need to use either an absolute path to the database or a path that contains a placeholder for the user.home directory if you put the files there.

See: http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_variables_url

fredt
  • 24,044
  • 3
  • 40
  • 61