slu

Søren's Blog

Random Ramblings

Previous Entry Share Next Entry
HSQLDB Part 1
computer
slu
I'm in the process of creating a small web site. Mainly for my own amusement.

I'm developing in Java, using JSP's and Servlets. The theme of the web site will be Java Technologies in general, with a focus on web development using Java.

As a back-end database I will be using HSQLDB. It's a small database writting 100% in Java.

I will now describe how I got HSQLDB working.

I'll asume that you have knowledge of Java and SQL, and a Java Development Kit and a servlet container installed. I'm currently using Sun's JDK 1.4.2 and Apache Jakarta Tomcat 5.0.28. Furthermore I'm using Gentoo Linux, so if you're using Windows a few changes are required (I'll try to note them, as I go along).

Start by downloading the latest realease, from SourceForge. The file to look for is called hsqldb_1_7_3_1.zip (posibly with a higher version number).

Unzip the archive. I have all my java related files below one common directory, /usr/java/ (c:\Java\ on Windows).

You now have a directory called hsqldb containing all files related to the database. I like to rename this directory to include the version number, e.g. hsqldb-1.7.3.1.

You should add hsqldb-1.7.3.1/lib/hsqldb.jar to you class path. Also you should copy it to your $CATALINA_HOME/common/lib and restart tomcat. You are now ready to compile/run Java-programs using hsqldb.

Run the manager: hsqldb-1.7.3.1/demo/runManager.sh (on Windows use runManager.bat). Enter the following:
Type: HSQL Database Engine Standalone
Driver: org.hsqldb.jdbcDriver
URL: jdbc:hsqldb:file:/path/to/your/app/demobase

Now create a table and put some data into it (click Execute-button after copying the following to the text field):

CREATE TABLE Bookmarks (title VARCHAR(50), url VARCHAR(255));
INSERT INTO Bookmarks (title, url) VALUES ('Java Technology', 'http://java.sun.com/');
INSERT INTO Bookmarks (title, url) VALUES ('HSQLDB 100% Java Database', 'http://hsqldb.sourceforge.net/');
INSERT INTO Bookmarks (title, url) VALUES ('Apache Jakarta Tomcat', 'http://jakarta.apache.org/tomcat/');
CHECKPOINT


The first four lines are standard SQL. The final line is HSQLDB specific.

You can test that it worked, by executing this:

SELECT * FROM Bookmarks ORDER BY title;

Exit the manager.

You now have four files in /path/to/your/app called demobase.log, demobase.properties and demobase.script (and if you didn't exit the manager, you'll also have a demobase.lck file). These three files describe your database, and can be copied to say a tomcat server.

This is the end of this part. The next part will show you how to write Java programs and servlets using the database.

  • 1

nice quick intro to hsqldb

(Anonymous)
Many thanks - very useful and direct to the point intro to hsqldb.

It doesn't work

(Anonymous)
java.lang.NoClassDefFoundError: org/hsqldb/store/BaseHashMap

Re: It doesn't work

(Anonymous)
Not a helpful comment - not enough detail - it worked for me!

Add'l info for 'demobase'

(Anonymous)
An example is worth 100 pages of yakking. The only thing I would add is that in the URL setting, "/path/to/your/app/" is relative to where "runManager.bat" is located. On my test, I created "data" subdirectory at same level as "demo", thus my URL read, "../hsqldb/data/demobase". Also, "demobase", it should be noted is the name of the new database. Thanks

Re: Add'l info for 'demobase'

(Anonymous)
Hi,

You are absolutely right!

Do you know where can I find a demo for how to load a text table using hsqldb?

Thanks.






















Great!

(Anonymous)
I agree its great to learn it from scratch

Thanks a lot for Your work!

(Anonymous)
Thanks a lot for what You are doing!Information, that I managed to find here
is extremely useful and essential for me!With the best regards!
Frank

Thanks

(Anonymous)
Well , frankly speaking this tutorials PWNED me .... thanks a TON and keep writting.

Very happy Mood = now mood :D

Ребятки, евсекннее голосование!

(Anonymous)
Ааану-ка ребятк голосуме!!!

Признавсйтесьпроказники и валадельыц сайта slu.livejournal.com ))))

ЧТО вы будете делать этим летом?!



















Re: Ребятки, евсекннее голосование!

(Anonymous)
ehh what?

Thank You for site

(Anonymous)
Thank you for your site. I have found here much useful information.
Good site ! ;)

FUNZIONA!

(Anonymous)
THANKS A LOT
it works.

a good simple, working example is worth some books.

thanks

HSQLDB problem

(Anonymous)
Hi,
I m using hsqldb 1.8.0.7 version. This version works fine bt sometimes i encounter the problem.
The problem is i have some data in the log file and whenever i m trying to start the server the data is not getting transfered in the script file as well as it is getting deleted from the log file.

Can anyone guide me for the solution of the above problem.

Hi,
I m using hsqldb 1.8.0.7 version. This version works fine bt sometimes i encounter the problem.
The problem is i have some data in the log file and whenever i m trying to start the server the data is not getting transfered in the script file as well as it is getting deleted from the log file.

Can anyone guide me for the solution of the above problem.

Please, help me, brothers!!!

(Anonymous)
Hello, my dear friends! I want to get program X-Rumer 5.07 Palladium for FREE. Have you any download link?
I'm so need this magic program! It's can break captchas automatically! Activate accounts via email automatically too! Absolutely great software! Help me!
And did you hear news - price for XRumer 5.0 Palladium will grow up to $540 after 15 may 2009... And XRumer 2.9 and 3.0 - too old versions, it's cant break modern catpchas and cant break modern anti-bot protections. But XRumer 5.0 Palladium CAN!!!!
So help me for download this great program for free! Thanks!

Re: Please, help me, brothers!!!

(Anonymous)
are u stupied or what??????? who cares what software u need, this site explains hsqldb, so do a favour to everyone: go and kill urself, bastard

Re: Please, help me, brothers!!!

(Anonymous)
Welcome to spam.

Nice Description

(Anonymous)
Its a very nice 5-minutes quick start guide.Awesome !!

  • 1
?

Log in