From Ruby to Groovy and Back

Well, I spent the entire morning trying to get DBI drivers for Oracle to work and I gave up before I wasted the entire day. First I had to figure out what libraries to use for database access. Why isn’t Ruby DBI just included with Ruby? Database access seems common enough to just include it. Anyway, I then had to try and get a DBI driver for oracle which required installing oracle clients and even then things often didn’t compile correctly. And of course, I’m using cygwin and windows which adds other complexity. And why should I have to compile drivers at all? I mean, yeah, I understand why, but it’s still a pain. I don’t do it for JDBC drivers, so why should I have to deal with this pain for Ruby?

I decided to just put the whole Ruby script on hold until I had more time to properly figure out the driver issues and moved on to Groovy instead. I still wanted to write this script in something different (for me) and I knew I could at least get Groovy to talk to my database without issue.

In fact, the final Groovy script was really simple and unless you knew better looked almost identical to Ruby. My only two complaints are that GroovySQL had trouble properly binding null values to my SQL insert statements and debugging the script in general was tricky. The closures kept eating my error messages so I would have to dismantle the script in order to figure out that, say, I had miss-typed part of my SQL query. Other than that, everything went smoothly. The script is nice and small and runs fast enough (which means slow, but I don’t care).

Today I came back to Ruby to do some simple text processing I normally would have done with awk and sed and that turned out really great. So maybe I’ll take another crack at those oracle drivers…