How connect to hsqldb database in jar?

B

Brzezi

Hi.

I`m writing a program, I`m usinig hsqldb database embded within it, finally
I`d like pack all application files including database files (*.backup,
*.data, *.script, *.properties) into one *.jar file, but I`v a problem, I
don`t know how to connect then to this database, I don`t know how the
jdbc URL to this databse should look like.

Has somebody done something like this?

Thanks in advance for any help.

Pozdrawiam
Brzezi
 
J

Jon Martin Solaas

Brzezi said:
Hi.

I`m writing a program, I`m usinig hsqldb database embded within it, finally
I`d like pack all application files including database files (*.backup,
*.data, *.script, *.properties) into one *.jar file, but I`v a problem, I
don`t know how to connect then to this database, I don`t know how the
jdbc URL to this databse should look like.

Has somebody done something like this?

Thanks in advance for any help.

Pozdrawiam
Brzezi

I'm not sure I understand what you want to do, but you can't store the
actual data-files for the database inside a jar file. Maybe, but not
very likely, there is some obscure feature of hsqldb that I don't know
about allowing you to do this, but generally, a database need to shrink
and grow it's data-files, delete files and create new ones. I don't see
how that could happen inside a jar-file.
 
B

Brzezi

sob, 16 pa¼ 2004 o 18:52 GMT, Jon Martin Solaas napisa³(a):
I'm not sure I understand what you want to do, but you can't store the
actual data-files for the database inside a jar file. Maybe, but not
very likely, there is some obscure feature of hsqldb that I don't know
about allowing you to do this, but generally, a database need to shrink
and grow it's data-files, delete files and create new ones. I don't see
how that could happen inside a jar-file.

I didn`t write it, database will be read only.
before I pack it into *.jar file, I will make database, after that
application will only read database...

I`v been trying many combinations of jdbc URL, but none worked :/

Pozdrawiam
Brzezi
 
A

Andrew Thompson

Beyond that, the way the D/B istelf is written to disk
may allow optimizations of fetching data by calc/direct or
other more efficient means of accessing the data.
I didn`t write it, database will be read only.
before I pack it into *.jar file, I will make database, after that
application will only read database...

I would guess this is not possible, even as read only,
but as an alternative, you ,ight try this.

Distribute the D/B inside the .jar, but when you go to use it,
check for it's existence (unzipped) in 'user.home' or similar,
if it is not where you expect it, fetch it out of the .jar and
write it to disk. The expansion should only rake a few moments,
once, thereafter the D/B can be read straight off disk.

HTH
 
B

Brzezi

sob, 16 pa¼ 2004 o 21:07 GMT, Andrew Thompson napisa³(a):
I would guess this is not possible, even as read only,
but as an alternative, you ,ight try this.

I`v just visited hsqldb homepage, and I saw new version since I were there
before, so I checked the changelog of this release, and now it is posible
connect to database which is placed in jar file... so my problem doesen`t
exist now :)

solution is:

jdbc:hsqldb:res:<path in jar>



Pozdrawiam
Brzezi
 
J

Jon Martin Solaas

Brzezi said:
sob, 16 pa¼ 2004 o 21:07 GMT, Andrew Thompson napisa³(a):
I`v just visited hsqldb homepage, and I saw new version since I were there
before, so I checked the changelog of this release, and now it is posible
connect to database which is placed in jar file... so my problem doesen`t
exist now :)

solution is:

jdbc:hsqldb:res:<path in jar>

Well, that's a feature that might come in handy one day, thanks for the
information ...
 
B

Brzezi

nie, 17 pa¼ 2004 o 20:27 GMT, Jon Martin Solaas napisa³(a):
Well, that's a feature that might come in handy one day, thanks for the
information ...

I wrote it, but I didn`t try it...
I wish it was so simple, but it isn`t, it doesen`t work :/

If I write URL like: jdbc:hsqldb:res:/myDbInJar
I catch SQLException:

java.sql.SQLException: Access is denied: wrong resource protocol: file

Has anybody any idea? it is still future feature? or it is working now?


Pozdrawiam
Brzezi
 
T

Thomas Kellerer

If I write URL like: jdbc:hsqldb:res:/myDbInJar
I catch SQLException:

java.sql.SQLException: Access is denied: wrong resource protocol: file

Has anybody any idea? it is still future feature? or it is working now?

You might want to post this question in the HSQLDB support forum on sourceforge.
The developers regularly read that and can most probably help you there.

http://sourceforge.net/forum/?group_id=23316

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top