Using JDBC to connect to Microsoft Access database

I’m doing a training tomorrow for which I needed to use a demo Microsoft Access database.
However, my laptop does not have ColdFusionMX 7 ODBC Server and ODBC Agent installed as Windows services. So, each time I try to setup a Microsoft Access datasource, I get a message:

The ColdFusion MX 7 ODBC Server service is not running or has not been installed.
You may also use the “MS Access with Unicode” driver to connect to MS Access datasources.

As I didn’t feel like manually installing the ODBC agent and server, I wondered if there was a way to simply use JDBC to connect directly to the Access database.
And there is.In ColdFusion Administrator, create a datasource of the type “other”. And use the following settings subsequently:

JDBC URL:

jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=[Full path to your database file];DriverID22;

Driver Class:

sun.jdbc.odbc.JdbcOdbcDriver

I prefer to always specify the Driver Name. It helps later to identify the database type from the datasource listing page. You can skip this if you don’t give a toss.

Drive Name:

MS Access via JDBC

Username, Password:

If the database requires any username, password, specify those.

Submit and and that’s it.

New Zealand Flex usergroup now active

I joined the newly-started New Zealand Flex user group today. It feels nice to be part of a growing community of users and developers who are embracing Flex down under.

I’ve been working with Flex, on and off, for over an year and a half now. It already feels like such a long time. And what makes me giddy with excitement is that it is just the beginning.

Well, anyway, here the URL for the NZ Flex usergroup: http://groups.google.com/group/nzfxug.

Good stuff, Kai and Campbell!

Search Engine Safe URLs on ColdFusion MX 6

Today I needed to enable the server-level search engine safe (SES) urls on a ColdFusion MX 6 server.

In the past I’ve referred to an Adobe technote for this. This technote shows how to accomplish this by adding a few servlet mappings to web.xml of the server.

I wanted to add the same mappings to a CF 6 server to enable SES urls. Howver, for some strange reason, the technote shows a screenshot of these mappings, which means that I can’t simply cut and paste them into my web.xml.

So here are the nodes for these mappings as “text” rather an “image”.

<!--If your J2EE server supports it, you can uncomment these.They are included to support Search Engine Safe (SES) URL types.Some servers (Tomcat, SunONE) don't support wildcard mappings-->
<!-- begin SES -->
<servlet-mapping id="macromedia_mapping_11">
 <servlet-name>CfmServlet</servlet-name>
 <url-pattern>*.cfml/*</url-pattern>
</servlet-mapping>

<servlet-mapping id="macromedia_mapping_12">
 <servlet-name>CfmServlet</servlet-name>
 <url-pattern>*.cfm/*</url-pattern>
</servlet-mapping>

<servlet-mapping id="macromedia_mapping_13">
 <servlet-name>CFCServlet</servlet-name>
 <url-pattern>*.cfc/*</url-pattern>
</servlet-mapping>
<!-- end SES -->
</pre>

Add these to the web.xml of your server, restart the server instance, and the any application (like BlogCFC) that makes use of search-engine safe urls will start working nicely.

A Songbird for Apollo

So I started going through my daily dose of information this morning. Found a link to this very interesting music player that describes itself as “desktop web player”. It is called Songbird.
Downloaded and started playing with it. Very impressive. Plays music stored locally and on the web with equal ease. Has a very nice feel to it — and it is still being developed!

But looking at it I couldn’t help but thinking how easy it would be to write something like this in Apollo.
Just need to get my hands on it!

A simple contact manager — a Flex-Cairngorm application

I finally got around to blogging a simple Cairngorm application that I had written a few months back just after completing my Flex Trainers’ training.

The application is a simple contact manager that allows for contacts to be listed, added, edited and searched. The backend uses ColdFusion to store information in memory. For the sake of simplicity of this application, I have deliberately not used a database and used session variables instead.

I wrote this app to get my head around key Cairngorm concepts. I found this really helped to understand the basics of the framework. This application uses Cairngorm 2.0.

If you are new to Cairngorm, have a look at cairngormdocs.org, especially the Cairngorm diagram.

To use this application you need Flex Builder 2 and ColdFusionMX 7.0.2.

Installation instructions:

  1. Unzip CFCairngormContacts.zip in the webroot of your ColdFusion server. This will create two folders:
    • CFCairngormContacts (containing the Flex code for the application and Cairngorm 2.0 SWC)
    • com (which contains ColdFusion code)
  2. Check ColdFusion backend by browsing to: http://yourserver/com/nagpals/examples/contact/index.cfm.If you see a couple of dumps and a message saying “Successfully retrieved contact list”, ColdFusion is setup correctly.If not, then you need to make sure this works first.
  3. Set up the app in Flex Builder.
    1. Create a new Flex project in Flex Builder.
    2. Select “ColdFusion Flash Remoting Service”
    3. Specify Root Folder as the the filesystem path to the ColdFusion server webroot.
      In my case: D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\
    4. Specify Root URL as the URL to the ColdFusion server.
      In my case: http://localhost:8300/
    5. Specify Project Name: CFCairngormContacts
    6. For Project Contents, uncheck the “Use default location” and select the location as the filesystem path to the ColdFusion server webroot.
      In my case: D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\
    7. Add a SWC to the project by going to Project > Properties > Flex Build Path > Library Path (tab) > Add SWC.
      Select the Cairngorm.swc in /CFCairngormContacts/com/adobe/cairngorm directory.
    8. Also make sure that the Flex Compiler arguments are setup to look at the correct services-config.xml. Project > Properties > Flex Compiler. The arguments are specified in the “Additional compiler arguments” field. In my case they read: -services “D:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\flex\services-config.xml” -locale en_US
    9. Run the application and you should see the Contact Manager load up in a browser.

TODO:

  • Add a running version of the application (my current host is not running CF 7.0.2)
  • Migrate it to Cairngorm 2.1
  • Add more information on how the application is structured

Do let me know if you get any issues in getting the app to run.
PS: The UI of the application is based on a similar application created by Robin Hilliard @ Rocketboots using Flex 1.5.