Patching SQuirreL-SQL

07 October 2003

SQuirreL-SQL is a slick little general-purpose SQL monitor written in Java that'll connect to anything with a JDBC driver. It's obviously, opensource, so I have the source and can make it do anything I want. The only problem with this arrangement is when the build process is too cumbersome, requiring external tools, libraries, whatever.

The release version of SQuirreL doesn't sort the db catalog list. This makes it difficult to find your proper catalog in the dropdown when the list is long. The code is so clean and well organized that I quickly found the implementation code for that dropdown and switched the HashMap that they were using to store the catalogs into a nice, automatically sorting TreeSet. I changed all of 5 lines of code.

Now, I needed to rebuild the project. Within my limited attention span, this proved to be too cumbersome, so instead, I realized that I could just run javac myself and include the pre-compiled fw.jar in my classpath. This allowed the compiler to rebuild my one tiny piece against the whole, without needing to build it all.

I could have then ripped open the fw.jar and dropped in my replacement, but it's even easier to just let the classloader do it for me, so I add a new directory, patch_classes, to the classpath before the fw.jar, drop my new class in there, and the classloader loads mine, since it finds it first. Now I have happy sorting catalog dropdowns with very little effort. In addition to being quick, this approach keeps my changes separate from the distribution, so I can easily re-apply my patched class to a newer release in the case that they have not fixed this for me (they have already, though, in cvs, but again, the build process was not worth my time).

Filed Under: