Learning to Love Railo

I have used the official ColdFusion since 1997 when it was owned by the Allaire brothers. I used it when Macromedia owned it. I used it when Adobe owned it. I have also used Open Blue Dragon and now I have used Railo. Given the price comparison, Railo is so far my favorite flavor of ColdFusion. Here’s a few reasons why and a small datasource IsItUp script.


One of the first things I noticed about Railo is how easily it installed on a 64-bit Windows 7 workstation. Running an exe or msi is always easy, but one thing that can make an app server install leave a sour taste is how complete the install is. Railo, I’m happy to report, includes drivers for a whole host of databases including Oracle, MS SQL, DB2, H2, PostgreSQL, MySQL and more.

Next, immediately after install, you can login to the administrator page and find a remarkable number of features and a navigation pattern that is very similar to the Adobe ColdFusion layout. This certainly lowers the learning curve. I proceeded to setup a datasource and found the layout still very similar to the historic ColdFusion gui. In under 30 minutes I was able to start coding a ColdFusion application.

First App

So I set out to create a small app to monitor datasources. I needed a quick page that users could hit to see if the problem was the database. I started out creating a hard-coded list of datasources to loop over to check. Then I found the handy cfadmin tag in Railo. The cfadmin tag has an action, getDatasources, that creates a query structure that lists the datasources. Obviously, this is a key to the kingdom and you should guard it carefully. On the other hand, it’s a key to the kingdom and oh there are so many wonderful things you can do with a key to the kingdom. The following lines of code is all there is to my datasource monitoring tool.

First, I use cfadmin to get a list of datasources.

Next, I query the cfadmin results to get just the columns I need and sort it.

Then, I use cfoutput to create dynamic queries against databases depending on the type of database.

Finally, I use cftry/cfcatch to show if the query to the datasource was successful.

It is a very simple but useful tool made even more simple by Railo’s cfadmin tag.

<html lang="en">
<title>Availability Monitor</title>
.pass { color: green;}
.fail { color: red; font-weight: bold; }
<cfadmin type="server" password="myPassword" action="getDatasources" returnVariable="ds">
<cfquery dbtype="query" name="dsList">select name, classname from ds order by name</cfquery>
<cfoutput query="dsList">
<cfif classname contains "oracle">
<cfquery datasource="#name#" name="q#name#" timeout="3">select sysdate from dual</cfquery>
<cfelseif classname contains "microsoft">
<cfquery datasource="#name#" name="q#name#" timeout="3">select getDate()</cfquery>
<p class="pass">#name# OK</p>
<p class="fail">#name# Unavailable</p>

Leave a Reply