0

I'm trying to use hsqldb in file mode with spring and hibernate, but the the database is not being initialized and i'm getting the following error message:

2015-03-12 23:58:35,542 FATAL [hsqldb.db.HSQLDB4C0FFF0D08.ENGINE]: could not reopen database
org.hsqldb.HsqlException: Database lock acquisition failure: lockFile:     org.hsqldb.persist.LockFile@6602b8e7[file =C:\User\db".lck, exists=false, locked=false, valid=false, ] method: openRAF reason: java.io.FileNotFoundException: C:\User\db".lck (The filename, directory name, or volume label syntax is incorrect)

My spring configuration is as following:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">

<tx:annotation-driven />
<context:component-scan base-package="org.oss.orm" />
<bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>db.properties</value>
    </property>
</bean>

<!-- data source -->
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="partitionCount" value="3" />
    <property name="acquireIncrement" value="10" />
    <property name="maxConnectionsPerPartition" value="60" />
    <property name="minConnectionsPerPartition" value="20" />
</bean>

<jdbc:initialize-database data-source="dataSource">
    <jdbc:script location="classpath:scripts/create-table-if-not-exists" />
</jdbc:initialize-database>

<!-- Session Factory -->
<bean id="sessionFactory" name="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="packagesToScan" value="org.oss.beans"></property>
    <property name="hibernateProperties">
        <props>
            <prop key="dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <!-- Create Tables if does not exist -->
            <prop key="hibernate.hbm2ddl.auto">create</prop>
        </props>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>org.oss.beans.Property</value>
            <value>org.oss.beans.PropertyImage</value>
        </list>
    </property>
</bean>

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager"
    p:sessionFactory-ref="sessionFactory">
</bean>

With the seperate properties file:

jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:file:#{systemProperties['user.home']}\\db"
jdbc.dialect=org.hibernate.dialect.HSQLDialect
jdbc.username=sa
jdbc.password=

What changes needs to be made for the db to be initialized?

Anhermon
  • 309
  • 3
  • 16
  • 1
    I think it must be `file://#{systemProperties['user.home']}\\db" ` – Jens Mar 12 '15 at 22:11
  • 2
    I don't think there should be a quotation mark (`"`) at the end of the `jdbc.url=jdbc:hsqldb:file:#{systemProperties['user.home']}\\db"` – esaj Mar 12 '15 at 22:16

0 Answers0