Results 1 to 8 of 8

Thread: HSQLDB problem

  1. #1
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default HSQLDB problem

    okay firstly, i was following one tutorial to create db.

    https://docs.google.com/viewer?url=h..._ch_hsqldb.pdf

    so i finished this and i have a database

    okay now i wanna run it from java program

    1) first i put the hsqldb.jar to my lib folder like this


    2) then i made a xml/ant file following a tutorial

    Using Hsqldb with your java development - Gridshore software engineering weblog

    this is what i have:

    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir="." name="poker">
    	
    	<!-- skripti muutujad !-->
    	
    	<property file="build.properties"/>
    	<property name="build.dir"           value="${basedir}/build"/>
        <property name="src.dir"             value="${basedir}/src" />
    	<property name="lib.dir"			 value="${basedir}/lib"/>
    	
    	<!-- db muutujad !-->
    	
    	<property name="path.to.db"			 value="${basedir}/db"/>
    	<property name="db.name"			 value="db"/>
    	<property name="user.id"			 value="sa"/>
    	<property name="user.pwd"			 value=""/>
        <property name="db.file"             value="${path.to.db}/${db.name}"/>
    	
    	
    	<!-- script algab siin !-->
    	
    	<target name="startdb">
    	  <echo message="Starting HSQLDB"/>
    	  <java fork="true" dir="." classname="org.hsqldb.Server">
    	    <classpath>
    	      <pathelement path="${lib.dir}/hsqldb.jar"/>
    	    </classpath>
    	    <arg value="-database.0"/>
    	    <arg value="${path.to.db}/${db.name}"/>
    	    <arg value="-dbname.0"/>
    	    <arg value="${db.name}"/>
    	  </java>
    	</target>
    	
    
    	<target name="setup_db"> 
    	  <sql 
    	    driver="org.hsqldb.jdbcDriver" 
    	    url="jdbc:hsqldb:hsql://localhost/${db.name}"
    	    userid="${user.id}"
    	    password="${user.pwd}"
    	    src="setup.sql"
    	    print="yes">
    	    <classpath>
    	      <pathelement location="${lib.dir}/hsqldb.jar"/>
    	    </classpath>
    	  </sql>
    	</target> 
    	
    	<target name="dbmanager">
    	  <echo message="Starting HSQLDB swing client"/>
    	  <java fork="true" dir="." classname="org.hsqldb.util.DatabaseManagerSwing">
    	    <classpath>
    	      <pathelement path="${lib.dir}/hsqldb.jar"/>
    	    </classpath>
    	  </java>
    	</target>
    </project>
    3) now when i run my db form the left..


    4) then first this pops out....

    5)but i want it to connect by itself to my db, not that i have to choose everything, like this:


    5) anyways the db works :


    6)and then i read a new tutorial..actually hsql documentation that i tried to use, but its not workin:




    so my db like works, but how i connect it with my java..so i can like do:
    create table or such commands

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    You need to ensure that jar file is included when you run the code.
    Somewhere in Eclipse (for the project) you should be able to tell it what libraries are required. You don't need ant or anything for that.

  3. #3
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default

    1) okay i added the jar file to path



    2) i ran this and nothing happened :


    3) so i added this line, and i got this error. it seems like database isn't running.

    WHOLE LOG:
    Java Code:
    Exception in thread "main" java.sql.SQLException: user lacks privilege or object not found: ITEMS
    	at org.hsqldb.jdbc.Util.sqlException(Util.java:215)
    	at org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1826)
    	at org.hsqldb.jdbc.JDBCStatement.executeQuery(JDBCStatement.java:181)
    	at Run.main(Run.java:16)
    Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ITEMS
    	at org.hsqldb.error.Error.error(Error.java:77)
    	at org.hsqldb.SchemaManager.getTable(SchemaManager.java:685)
    	at org.hsqldb.ParserDQL.readTableName(ParserDQL.java:5257)
    	at org.hsqldb.ParserDQL.readTableOrSubquery(ParserDQL.java:1662)
    	at org.hsqldb.ParserDQL.XreadTableReference(ParserDQL.java:1066)
    	at org.hsqldb.ParserDQL.XreadFromClause(ParserDQL.java:1053)
    	at org.hsqldb.ParserDQL.XreadTableExpression(ParserDQL.java:988)
    	at org.hsqldb.ParserDQL.XreadQuerySpecification(ParserDQL.java:982)
    	at org.hsqldb.ParserDQL.XreadSimpleTable(ParserDQL.java:966)
    	at org.hsqldb.ParserDQL.XreadQueryPrimary(ParserDQL.java:895)
    	at org.hsqldb.ParserDQL.XreadQueryTerm(ParserDQL.java:861)
    	at org.hsqldb.ParserDQL.XreadQueryExpressionBody(ParserDQL.java:840)
    	at org.hsqldb.ParserDQL.XreadQueryExpression(ParserDQL.java:814)
    	at org.hsqldb.ParserDQL.compileCursorSpecification(ParserDQL.java:5409)
    	at org.hsqldb.ParserCommand.compilePart(ParserCommand.java:133)
    	at org.hsqldb.ParserCommand.compileStatements(ParserCommand.java:88)
    	at org.hsqldb.Session.executeDirectStatement(Session.java:1170)
    	at org.hsqldb.Session.execute(Session.java:972)
    	at org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1818)
    	... 2 more
    4) so i thought, okay..ill run the db then..so i ran the db from ant..db as database manager which also runs database.


    5) and then again, i ran my main classs:

    WHOLE LOG:

    Java Code:
    Exception in thread "main" java.sql.SQLException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile@a4d71f6d[file =C:\Users\Jansu\workspace\poker\db\db.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2010-12-22 14:57:53 heartbeat - read: -2700 ms.
    	at org.hsqldb.jdbc.Util.sqlException(Util.java:380)
    	at org.hsqldb.jdbc.Util.sqlException(Util.java:103)
    	at org.hsqldb.jdbc.JDBCConnection.<init>(JDBCConnection.java:3303)
    	at org.hsqldb.jdbc.JDBCDriver.getConnection(JDBCDriver.java:321)
    	at org.hsqldb.jdbc.JDBCDriver.connect(JDBCDriver.java:259)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at Run.main(Run.java:14)
    Caused by: org.hsqldb.HsqlException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile@a4d71f6d[file =C:\Users\Jansu\workspace\poker\db\db.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2010-12-22 14:57:53 heartbeat - read: -2700 ms.
    	at org.hsqldb.error.Error.error(Error.java:77)
    	at org.hsqldb.persist.LockFile.newLockFileLock(LockFile.java:642)
    	at org.hsqldb.persist.Logger.acquireLock(Logger.java:1076)
    	at org.hsqldb.persist.Logger.openPersistence(Logger.java:284)
    	at org.hsqldb.Database.reopen(Database.java:220)
    	at org.hsqldb.Database.open(Database.java:186)
    	at org.hsqldb.DatabaseManager.getDatabase(DatabaseManager.java:240)
    	at org.hsqldb.DatabaseManager.newSession(DatabaseManager.java:157)
    	at org.hsqldb.jdbc.JDBCConnection.<init>(JDBCConnection.java:3281)
    	... 5 more
    so..i got this error..i googeled it and searched everywhere..didn't get any help..anyone?

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    You can only have one person accessing the db I think.
    I'm not so big on HSQL so I can't confirm it, but the same thing happens with Embedded Derby.

    So, going back to the first error (the items table not found), does that table actually exist?

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    Oh, and the db is loading up otherwise you'd get an error on making the connection.

  6. #6
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    You can only have one person accessing the db I think.
    I'm not so big on HSQL so I can't confirm it, but the same thing happens with Embedded Derby.

    So, going back to the first error (the items table not found), does that table actually exist?
    yes you are right, HSQL only allows one connection..or atleast what i've figured out that when im using the HSQL standalone engine, which i am, it doesn't allow more connections than one.

    and about the query...i think i made a type, as you can see from top, i have table ITEM not ITEMS.

  7. #7
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    Yep, the standalone sounds like the embedded one then.

    Does it work now you've corrected the typo?

  8. #8
    Char's Avatar
    Char is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Yep, the standalone sounds like the embedded one then.

    Does it work now you've corrected the typo?
    well yes it does, its not doin anything yet..since it querys the table..but it doesn't have any output.

    ill mess around with it for a while and come back when i have some questions

Similar Threads

  1. Hsqldb
    By Abder-Rahman in forum JDBC
    Replies: 1
    Last Post: 10-20-2009, 11:11 AM
  2. Hsqldb
    By Abder-Rahman in forum JDBC
    Replies: 1
    Last Post: 10-20-2009, 11:10 AM
  3. can't load the driver (hsqldb)
    By tomiu in forum JDBC
    Replies: 7
    Last Post: 06-09-2009, 11:23 PM
  4. Replies: 0
    Last Post: 02-13-2009, 06:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •