Mark Drew (Redux)- cf_etc...

a compendium of railo, cfml, cfeclipse and technology topics

Mark Drew (Redux)- cf_etc...

Coldfusion 8: Creating a Derby database

June 7, 2007 ·

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/

Tags: coldfusion · webdev

5 responses

  • 1 Dan G. Switzer, II // Sep 22, 2008 at 4:10 PM

    Nice post... Much simplier solution than what Ben Forta posted a few days back.
  • 2 Dean Glasener // Sep 22, 2008 at 4:10 PM

    Thanks for this info. Would addin a "H2 Database" follow the same technique with 'Other as the DNS type'
    Thanks Dean
  • 3 Marc Henkel // Sep 22, 2008 at 4:10 PM

    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.?
  • 4 Mark Drew // Sep 22, 2008 at 4:10 PM

    @Marc: Sounds like a perfect place to add client variables.
    @Dean: Not sure... never used H2
  • 5 Steve Bryant // Sep 22, 2008 at 4:10 PM

    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/