You are viewing slu

Previous Entry | Next Entry

HSQLDB Part 1

computer
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.

Comments

( 19 comments — Leave a comment )
(Anonymous)
Jun. 25th, 2005 08:01 am (UTC)
nice quick intro to hsqldb
Many thanks - very useful and direct to the point intro to hsqldb.
(Anonymous)
Oct. 11th, 2005 04:24 am (UTC)
It doesn't work
java.lang.NoClassDefFoundError: org/hsqldb/store/BaseHashMap
(Anonymous)
Oct. 21st, 2005 08:59 pm (UTC)
Re: It doesn't work
Not a helpful comment - not enough detail - it worked for me!
(Anonymous)
Nov. 5th, 2005 03:37 pm (UTC)
Add'l info for 'demobase'
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
(Anonymous)
Sep. 2nd, 2006 07:39 pm (UTC)
Re: Add'l info for 'demobase'
Hi,

You are absolutely right!

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

Thanks.





















(Anonymous)
Mar. 17th, 2006 02:10 pm (UTC)
Great!
I agree its great to learn it from scratch
(Anonymous)
Feb. 1st, 2007 06:29 am (UTC)
Thanks a lot for Your work!
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
(Anonymous)
Mar. 1st, 2007 09:50 am (UTC)
Thanks
Well , frankly speaking this tutorials PWNED me .... thanks a TON and keep writting.

Very happy Mood = now mood :D
(Anonymous)
May. 13th, 2007 10:46 am (UTC)
Ребятки, евсекннее голосование!
Ааану-ка ребятк голосуме!!!

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

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


















(Anonymous)
Jul. 30th, 2007 01:04 pm (UTC)
Re: Ребятки, евсекннее голосование!
ehh what?
(Anonymous)
Aug. 27th, 2007 06:29 am (UTC)
Thank You for site
Thank you for your site. I have found here much useful information.
Good site ! ;)
(Anonymous)
Oct. 20th, 2008 02:05 pm (UTC)
FUNZIONA!
THANKS A LOT
it works.

a good simple, working example is worth some books.

thanks
(Anonymous)
Dec. 3rd, 2008 11:33 am (UTC)
HSQLDB 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.
ankurmaheshwari
Dec. 3rd, 2008 11:34 am (UTC)
HSQLDB 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.
(Anonymous)
Apr. 30th, 2009 03:09 pm (UTC)
Please, help me, brothers!!!
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!
(Anonymous)
May. 23rd, 2009 09:43 pm (UTC)
Re: Please, help me, brothers!!!
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
(Anonymous)
Dec. 11th, 2009 08:04 am (UTC)
Re: Please, help me, brothers!!!
Welcome to spam.
besendorfer
Dec. 7th, 2009 09:46 am (UTC)
Happy Birthday!
(Anonymous)
Jan. 19th, 2011 05:30 pm (UTC)
Nice Description
Its a very nice 5-minutes quick start guide.Awesome !!
( 19 comments — Leave a comment )