Question

Hi i created a Hibernate powered hsql embedded swing app..When i run eclipse juno version it run perfectly..After that i export as runnable jar file as run it.But does not retrieve,add data database...!!!

Project directory like

Project ..src .....dao .....daoimpl .....sevice .....serviceimpl .....domain .....main .....hibernate.cfg.xml ..db/hsql/library .............library.script

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
  <session-factory>
    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.HSQLDialect</property> 

    <!-- Database connection settings --> 
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="hibernate.connection.url">jdbc:hsqldb:db/hsql/library;shutdown=true</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password">sa</property>
        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>


    <!-- JDBC connection pool (use the built-in one) -->
    <property name="connection.pool_size">1</property> 

    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>

    <!-- Disable the second-level cache  --> 
    <property
     name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

    <!-- disable batching so HSQLDB will propagate errors correctly. -->
    <property name="jdbc.batch_size">0</property> 

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property> 

    <!-- List all the mapping documents we're using --> 
    <mapping class="com.habitz.librarymanagement.domain.Admin" />
        <mapping class="com.habitz.librarymanagement.domain.Book" />
        <mapping class="com.habitz.librarymanagement.domain.Category" />
        <mapping class="com.habitz.librarymanagement.domain.Group" />
        <mapping class="com.habitz.librarymanagement.domain.Issue" />
        <mapping class="com.habitz.librarymanagement.domain.Member" />
  </session-factory>
</hibernate-configuration>

Someone know please help...!!

Was it helpful?

Solution

This property creates a database relative to where the jar was executed from.

<property name="hibernate.connection.url">jdbc:hsqldb:db/hsql/library;shutdown=true</property>

Relative URL's do not work. Use an absolute URL. For example, you can use the user's directory for the database files, or a directory that your app is installed in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top