• (2 Pages)
  • +
  • 1
  • 2

Inserting Java objects into an HSQLdb database Rate Topic: ***** 4 Votes

#16 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,913
  • Joined: 06-March 08

Posted 01 April 2013 - 03:34 PM

/** This to test our code in StandAlone mode */
public class TestStandAlone {

	public static void main(String[] args) {
		new DbTable("DICdb");
		// this is important it says to the DB to keep the table definition even if the table is empty
		// so if you do not populate the DataBase but just create the tables uncomment the following statement
//		DbTable.getInstance().statementExecute("SHUTDOWN COMPACT;");

	}
}


Was This Post Helpful? 1
  • +
  • -

#17 tfoman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-March 13

Posted 04 April 2013 - 01:54 PM

Thanks for the TestStandaloneClass !
It was quite simple, so i would have imagined trying that myself.
I'm sorry i cant make it run even if i have copied all classes' code and compiled it together successfully.
I use hsqldb-2.2.9, jdk1.7.0_09 and windows 8 and i can see that the db-files are created and stored after stopped run.
it seemes there is an authentication issue or do i use the wrong version of any component?
(I can run the tests from installing the database and databasemanager etc.)
Do you have an idea about why i don't succeed ?
Here are the results i encounter !

"C:\Program Files\Java\jdk1.7.0_09\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:7770,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_09\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_09\jre\lib\ext\zipfs.jar;C:\hsqldb\lib\hsqldb.jar;C:\IntelliJProjs\dbTest\out\production\dbTest;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.0.3\lib\idea_rt.jar" se.tfoman.db.TestStandAlone
Connected to the target VM, address: '127.0.0.1:7770', transport: 'socket'
Constructor of DbTable in StandAlone mode
HSQLdb driver correctly loaded.
Correctly connected in StandAlone mode.
queryExecute building prepStatement SELECT COUNT(*) FROM FirstNameTable; returns -5501 java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: FIRSTNAMETABLE
GetCount() on FirstNameTable returns -1
statementExecute: org.hsqldb.jdbc.JDBCPreparedStatement@89f987a[sql=[Create Cached Table FirstNameTable (Obj OBJECT, Id INTEGER IDENTITY PRIMARY KEY, Name VARCHAR(1024) NOT NULL, UNIQUE (Id), UNIQUE (Name));]]
status: -5522>> java.sql.SQLSyntaxErrorException: a UNIQUE constraint already exists on the set of columns in statement [Create Cached Table FirstNameTable (Obj OBJECT, Id INTEGER IDENTITY PRIMARY KEY, Name VARCHAR(1024) NOT NULL, UNIQUE (Id), UNIQUE (Name))]
Exception in thread "main" java.lang.IllegalStateException: Problem creating PreparedStatement for FirstNameTable.
at se.tfoman.db.FirstNameTable.<init>(FirstNameTable.java:59)
statementExecute(Create Cached Table FirstNameTable (Obj OBJECT, Id INTEGER IDENTITY PRIMARY KEY, Name VARCHAR(1024) NOT NULL, UNIQUE (Id), UNIQUE (Name));) returns -1
at se.tfoman.db.DbTable.createTables(DbTable.java:107)
StatementExecute building prepStatement for ALTER TABLE FirstNameTable ALTER COLUMN Id RESTART WITH 1; returns: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: PUBLIC.FIRSTNAMETABLE
at se.tfoman.db.DbTable.<init>(DbTable.java:55)
statementExecute(ALTER TABLE FirstNameTable ALTER COLUMN Id RESTART WITH 1;) returns -1
at se.tfoman.db.TestStandAlone.main(TestStandAlone.java:13)
Problem creating PreparedStatement for FirstNameTable.
Disconnected from the target VM, address: '127.0.0.1:7770', transport: 'socket'

Process finished with exit code 1


Thanks in advance

Tommy
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2