HQSLDB
Folks,
My Issue
Why is an HSQLDB file-based database I have pre-populated with a schema and data not populated when I connect to it later?
I think I'm missing some small, but HUGELY IMPORTANT configuration.
My Environment
Steps to Populate the Database and Run the App
Run the Sql Maven plugin to create 3 schemas in the HSQL database
Run the Maven liquibase plugin, populating with ddl and lookup data
The jdbc url I'm using within Maven to setup hsql is: jdbc:hsqldb:file:${project.basedir}/target/db/build;shutdown=true
.
It translates to: jdbc:hsqldb:file:/Users/myHomeDir/work/myProj/target/db/build;shutdown=true
I have confirmed the the hsql database files are created and populated -- insert statements in the build.script file are present as expected. I can connect to the database using RazorSQL and see the data and tables present.
Running the App
I've configured my DataSource in my Spring config as follows:
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:/Users/myHomeDir/work/myProj/target/db/build;shutdown=true" />
<property name="username" value="sa" />
<property name="password" value="" />
I've fired up the app and see that Hibernate/Spring makes the connection to the database. A database.lck file is created so I know the app has made a connection. (Also, I've ensured that RazorSQL is shutdown and not using the database at the same time).
The Error
The error indicates that the database entities don't exist:
[INFO] Started Jetty Server
Hibernate:
select
this_.id as id5_2_,
this_.created_date as created2_5_2_,
this_.creating_user_id as creating3_5_2_,
this_.email as email5_2_,
this_.first_name as first5_5_2_,
this_.is_enabled as is6_5_2_,
this_.last_login_date as last7_5_2_,
this_.last_modified_date as last8_5_2_,
this_.last_modifying_user_id as last9_5_2_,
this_.last_name as last10_5_2_,
this_.login as login5_2_,
this_.middle_initial as middle12_5_2_,
this_.password_hash as password13_5_2_,
this_.password_history as password14_5_2_,
this_.suffix as suffix5_2_,
roles2_.user_id as user1_5_4_,
role3_.id as role2_4_,
role3_.id as id3_0_,
role3_.code as code3_0_,
role3_.description as descript3_3_0_,
role3_.name as name3_0_,
role3_.type_id as type5_3_0_,
roletype4_.id as id4_1_,
roletype4_.description as descript2_4_1_
from
security.user this_
left outer join
security.user_role roles2_
on this_.id=roles2_.user_id
left outer join
security.role role3_
on roles2_.role_id=role3_.id
left outer join
security.role_type roletype4_
on role3_.type_id=roletype4_.id
where
this_.login=?
[01/20/2012 17:30:18,440] WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: -5501, SQLState: 42501
[01/20/2012 17:30:18,440] ERROR: org.hibernate.util.JDBCExceptionReporter - user lacks privilege or object not found: USER
2012-01-20 17:30:18.443:WARN::/my-webapp/j_spring_security_check
org.hibernate.exception.SQLGrammarException: could not execute query
Just to make sure, can't it be caused by conflict of table name ( USER
) with SQL keyword?
Try to use different table name instead, or at least configure Hibernate to escape it ( @Table(name = ""user"")
).
下一篇: HQSLDB