Coldfusion 8: Creating a Derby database

Posted At : June 7, 2007 4:44 PM | Posted By : Mark Drew
Related Categories: coldfusion, derby

I am not sure how many people noticed but ColdFusion 8 now comes with an in-built database called Apache Derby. This is great for people needing to deploy applications that need a little database that might be highly performant but without the need for complex queries etc. (read SnipEx here).

To get you started, it comes with the sample applications already installed, but what if you want to create your own database, and point a datasource to it?

Well, help is at hand, this is what I did to create a test database and point a DSN to it:

Firstly, go to (in a terminal window) the directory where you will create the database files, in my case I was going to create it under /Applications/ColdFusion8/db/ .

Then run the following command:

> java -jar /Applcations/ColdFusion8/lib/derbyrun.jar ij
(obviously substituting your path to the jar). Once you have done that, you can now create a database by entering:

ij> connect 'jdbc:derby:cfeclipse_test;create=true';

Where cfeclipse_test is the name of your database, to exit just type "exit ;"

Now that you have created the database you can create a DSN entry for it, all you have to do is create a DSN of type "Apache Derby Embedded" and point it to the folder where you created the databse, in this case it would be "/Applications/ColdFusion8/db/cfeclipse_test"

It should all now work, and you have a DSN to create your tables and run your queries against.

For more info on Derby, check out: http://db.apache.org/derby/docs/dev/getstart/

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Dan G. Switzer, II's Gravatar Nice post... Much simplier solution than what Ben Forta posted a few days back.
# Posted By Dan G. Switzer, II | 6/7/07 6:31 PM
Dean Glasener's Gravatar Thanks for this info. Would addin a "H2 Database" follow the same technique with 'Other as the DNS type'
Thanks Dean
# Posted By Dean Glasener | 6/7/07 7:05 PM
Marc Henkel's Gravatar For those of us who use client variables and store them in a SQL database, I wonder if Derby will be a better solution than MySQL, SQL Server, Oracle, etc.?
# Posted By Marc Henkel | 6/7/07 10:23 PM
Mark Drew's Gravatar @Marc: Sounds like a perfect place to add client variables.
@Dean: Not sure... never used H2
# Posted By Mark Drew | 6/8/07 6:44 AM
Steve Bryant's Gravatar I should have drawn more attention to it in my entry, but the best resource I have found for Derby so far is the documentation here:

http://db.apache.org/derby/docs/10.2/ref/
# Posted By Steve Bryant | 6/8/07 8:10 PM