Multiple Java Applications accessing one HSQLDB causes app to hang -


this semi-related previous question. previous question states, have desktop app calls off different main method kick off particular process. both desktop app , separate main method access same hsqldb database.

prior getting far, desktop app had been accessing hsqldb database using connection url one:

jdbc:hsqldb:file:/some/path/mydatabase 

now works fine in single user environment. i've got multi-user environment desktop app , separate main process wanting read/write to/from database, wanted make database shared resource.

i've had @ hsqldb documentation , post creating shared hsqldb database no avail.

in post talks starting server via code. don't think want have hsqldb database , running time there multiple users of desktop app.

looking @ official hsqldb documentation, states can start hsqldb server this:

java -cp ../lib/hsqldb.jar org.hsqldb.server -database.0 file:mydb -dbname.0 xdb 

if run above command own database file , name, seems start okay:

[server@6ca1c]: [thread[main,5,main]]: checkrunning(false) entered [server@6ca1c]: [thread[main,5,main]]: checkrunning(false) exited [server@6ca1c]: startup sequence initiated main() method [server@6ca1c]: loaded properties [/some/path/mydatabase/server.properties] [server@6ca1c]: initiating startup sequence... [server@6ca1c]: server socket opened in 16 ms. 

i changed connection url following:

jdbc:hsqldb:hsql://localhost/xdb 

this not seem work me. ideas i've done wrong or missing?

furthermore, when desktop app calls off external main method desktop app hangs external main method notices desktop app seems have lock on database. shut down desktop app, external main method expected do.

using jdbc:hsqldb:file:/some/path/mydatabase creating in-process database should not shared between multiple jvm (ideally), there way per guide

"in 1.8.0, can run server instance in thread same virtual machine application , provide external access in-process database."

imho, better way start in server mode in separate jvm.

update:

check log when hsqlsdb server starting up:

[server@83cc67]: initiating startup sequence... [server@83cc67]: server socket opened in 31 ms. [server@83cc67]: database [index=0, id=0, db=file:test, alias=] opened sucessfully in 250 ms. 

match alias name in driver url

connection c = drivermanager.getconnection("jdbc:hsqldb:hsql://localhost/", "sa", ""); 

in case there no alias. tested , works fine.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -