I was called by my boss to work on a tough problem. The previous developer spent a week on it and got nowhere. Great. Now the pressure was on. I was given a day to figure things out. So I got down to business. Had to try many things to replicate the problem in a development environment.
Sometimes I needed to update configuration data in the database. Most of the time I had to run some queries to figure out which values needed to be updated. Or I needed to run some specific pieces of some jobs, which turned out to be stored procedures. I figured there had to be a speedier way to do all this.
There is a better way. Create a tool to automate what I need done. What better language to implement this tool than Java? Figured I would use the easiest database access method I could think of. That would be JDBC. Unfortunately the last time I played with JDBC, I used it with a MySQL database that was running on my computer. Now I needed to access an Oracle database running on some huge server.
Luckily most of the ideas in JDBC transcend specific database choice. Just had to figure out the connect string. Turns out I could use an OCI driver that made use of a TNSNAMES alias. That was sweet. Took a while to get it working though. The real breakthrough came when I read the release notes for my Oracle 11g client that was installed locally. Turns out I needed to ensure a JDBC jar file was in my classpath.
My initial cut was a little slow for each action. That's becuase I was creating and closing out a session every time a task needed to be executed. Instead I need to refactor this to reuse one database connection that gets established when my tool starts up. That should be an easy enough fix. I wonder whether it is time to share my little tool with the other developers on my team?