WebDevelopment, ColdFusion, Railo, JS, Database and Tech-related by the Co-Founder and CEO of tunesBag.com

Thursday, 11 June 2009

Using the H2 database in ColdFusion

Railo is delivered with an embedded database called H2. The description on the homepage says:

Welcome to H2, the Java SQL database. The main feature of H2 are:

* Very fast, open source, JDBC API
* Embedded and server modes; in-memory databases
* Browser based Console application
* Small footprint: around 1 MB jar file size

Such a database fit's perfectly for a current task at tunesBag - the streaming servers should store some data on their own machines and mysql or postgresql just would be overkill for this task. So I decided to give H2 a look and it looks pretty nice.

On my local machine I'm working with ColdFusion 8 as well - the configuration to add H2 support for CF is very easy, just follow the following steps:

  • Download the latest version of H2
  • Drop the h2*.jar file in the WEB-INF/lib directory of your ColdFusion server (directory depends on your type of setup)
  • Restart CF
  • Add a new datasource
  • JDBC URL = jdbc:h2:file:%Path to Database file on your disk%
  • Driver Class = org.h2.Driver
  • Driver name = default
  • User name = sa

That's it - the files holding the data will be created automatically for you. Take a look at the H2 tutorial in order to find out more (e.g. server mode etc).


Tom Chiverton said...

Why is H2 better than the Derby database built into Adobe's CF server ?

Hansjoerg said...

I started playing around while using the latest version of Railo (railo is bundled with H2) and it worked pretty well so I decided to use it on ColdFusion as well, so no special preference is involved.

jackob said...

Such a well written post.. Thnkx for sharing this post!
Thank You
ColdFusion Developer

raj said...

This is good stuff.

However I couldn't achieve the results using cold-fusion and h2 database.
1. I used the driver with this string "jdbc:h2:file:C:\mydb;MODE=MSSQLServer", I was able to connect and dump anything from information_schema but could not connect to user defined tables. The error message was Table not found.
2. Simply I was unable to connect using the following string
Error Msg: "90067-146"

Raj Sankar

Wim said...

I'm having trouble using H2 BLOBS in ColdFusion. Whenever I do a select which should return a BLOB, I get a "file not found" error.

johnbond said...

Thanks a lot for enjoying this beauty blog with me. I am appreciating it very much! Looking forward to another great blog. Good luck to the author! all the best!

savsuns said...

Before reading this I was totally unaware of the topic. Thanks for Explaining in such a nice way. As per my knowledge there some buy lasix which are effective and good. I always prefer them only.

Chris Suja said...

Once again thank you for sharing this list of blogs! I like how your website has Tadalafil Online very clean and simple style, but also very elegant at the same time.

Seo Mumbai said...

Hi , i got this Article , i was searching some thing relevant to this, And i am feeling lucky, as its the perfect one for what i am looking for. I will share this link on face book.
Rummy Online

danial11 said...

I was searching some thing relevant to this, And i am feeling lucky, as its the perfect one for what i am looking for. I will share this. six sigma training

vinay said...

poker hands
I like to work with H2 database. It is very relevant for me.It is also very easy to install.

Brock Kutchera said...

atlanta hotels buckhead

Really beautiful! The articles are very informative. I am hoping the same best work from you in the future as well.

Althea Eno said...

wow....! Very nice and useful article. Your way of explanation is beautiful. I learn a lot of things from your article. The stuff you are using that is very useful and helpful. Thanks for sharing a very informative article.

how to get a girlfriend