HSQLDB
As soon as you have installed Railo you are able to use the build in database called HSQLDB. Since HSQLDB is a file based Java database we were able to implement it by default in Railo. The only thing you have to do is to add a new datasource of the type HSQLDB.Note: The underlying database in Railo 1.1 is in fact H2DB. This is just the descendant project of HSQLDB.
Below is shown what options are available when creating a HSQLDB datasource in the Railo Administrator.
Note: In the path definition (as evrywhere in Railo) you can use relative or absolute paths. You can even use the constant paths ({railo-web},{temp-directory}, etc.). I will address these path constants in a later blog.
After creating the datasource (the database does not need to exist yet) you can access the database by creating tables, filling them and querying them accordingly.
Like for example:
<cfquery name="createTable" datasource="myTest">
CREATE TABLE tblBlogCategories (
categoryid varchar(35) NULL ,
categoryname varchar(50) NULL ,
categoryalias varchar(50) NULL ,
blog varchar(50) NOT NULL ,
CONSTRAINT PK_tblBlogCategories PRIMARY KEY
(
categoryid
)
)
</cfquery>
After creating the table you can access it as usual. For instance,inserting a record:
<cfquery name="insertRecord" datasource="myTest">
INSERT INTO tblBlogCategories (categoryid, categoryname, categoryalias, blog) VALUES ('4711','My category','mine','myBlog')
</cfquery>
and querying the table:
<cfquery name="getRecords" datasource="myTest">
Select * from tblBlogCategories
</cfquery>
<cfdump eval="getRecords">At the moment you need to add the data manually or use one of the tools available for HSQL. But for small applications that do not require a high performant database server, HSQLDB is a good choice.
More about HSQL db can be read on their homepage.
12 responses so far ↓
1 Jeff G // Jan 8, 2007 at 2:54 PM
2 Gert Franz // Jan 8, 2007 at 3:00 PM
Since Railo uses HSQLDB for supporting QoQ, the QoQ Syntax allows anything that HSQLDB allows. It is ANSI92 compatible.
Besides that, if someone hosts Railo and has no way to access a database for what reason ever, he can use the builtin HSQLDB.
Oh, and since it is file based HSQLDB is great if you want to distribute an Railo application from a CDROM.
But I agree that for larger applications, HSQLDB is the wrong choice.
Gert
3 Jeff G // Jan 8, 2007 at 4:28 PM
4 Gert Franz // Jan 8, 2007 at 4:34 PM
But I allways recommend not to use QoQ if possible. It is almost allways slower than querying a database server. But I'm sure there are cases when QoQ is doing the job better than other sollutions...
5 Alan // Jan 9, 2007 at 10:25 AM
The BlueDragon implementation is seriously fast
6 Gert Franz // Jan 9, 2007 at 10:56 AM
But I can hardly agree with your statement that QoQ out performs the database in the majority of cases since:
- QoQ is not aware of indexes
- QoQ has limited syntax
- QoQ is not aware of prepared statements
- QoQ is not aware of execution plans
- QoQ consumes lots of memory and processor power
But, I agree that in some cases it can be easier to use and faster to execute than doing it all on the database server (if even possible). If BD's sollution of QoQ is faster than our implementation, then we'll take a closer look on QoQ performance for the Railo 1.1 release.
Gert
7 Streit // Jan 9, 2007 at 9:16 PM
8 Ron Stewart // May 8, 2007 at 3:45 PM
The only way I can get this to work is to use just the path with no placeholder when I create the datasource (e.g., just "TestDB"), in which case it creates it in the Railo directory (e.g., ~/opt/railo-1.1 on my system).
Is this a known problem with the directory placeholders in the beta, or perhaps unique to the Mac OS platform?
9 Gert Franz // May 8, 2007 at 10:40 PM
Sorry that I confused you.
You can use something like this:
/db/TestDB.db
It is not a problem of Railo in the Beta and no particular problem to Mac OSX (in fact we develop Railo under Mac OSX :-).
Have fun
Gert
10 Ron Stewart // May 9, 2007 at 1:56 PM
11 Gert Franz // May 9, 2007 at 2:19 PM
<cfinclude template="{railo-web}/...>
I will post here as soon as this feature is available.
Gert
Hope to meet you all at Scotch on the Rocks
12 Streit // May 9, 2007 at 2:56 PM
first make a mapping like this:
physical:{temp-directory}; virtual:/temp
now you can use the temp directory as follows:
<cfinclude template="/temp/myfile.cfm">
<cfdirectory source="/temp/myfile.txt">
if you rewrite the hsqldb driver a liitle bit, this also wok there.
you can find the hsqldb driver here:
/WEB-INF/railo/context/admin/dbriver/HSQLDB.cfc
(we also will in future versions)
in a first step we wil support this placeholders for the BIF "expandPath", if we will support for all file operations is not shure at the moment.
greetings michael
Leave a Comment