In case you don't want to re-invent the wheel, there is a popular automation software package called
Ignition that features cross-platform support (Java) and is based on integration with SQL databases.
I'm running it on an Ubuntu 10.04 server (a tiny little FitPC2) with MySQL. Even without the visualization package it's a tidy and relatively inexpensive transaction manager for Logix-family controllers and SQL. One of my customers for it, by coincidence, is in Edmonton.