Spring JDBC is awesome

I would like to just take a moment to express my love for Spring JDBC. I just deleted giant swaths of database connection handling code from an app I’m maintaining by replacing a DAO with a Spring JDBC version. If you haven’t taken the time to learn about it, check it out here.

Moving code from one SVN to another

I am currently working on merging some of the projects from two different SVN repositories to one repository. I don’t want to do a full dump of one and restore to the other, because the organization is a bit different in each. The solution is something like this:

  1. Dump the entire source repository
  2. Use svndumpfilter to split the dump into separate files
  3. Import each file separately into the right spot in the target repository

Here’s a couple one-liners to split the dump file (I love Unix):

$ cat source_repo.dump |grep -a ^Node-path: | grep -v / |uniq | sed “s/Node-path: //g” > projectlist.txt
$ for i in `cat projectlist.txt`; do cat svn_oasis.dump | svndumpfilter include $i > $i.dump; done

The first command creates a list of top level directories, and the second does the splitting. Now, you have a separate dump file for each different top level directory in the source repo. This can be tweaked if you want to split it based on different criteria.

Once you have the dump file for a project and you want to import it, you use a command like this:

cat project.dump | svnadmin load /usr/local/svn/myrepo

Make sure that the path you are importing doesn’t exist. I did not make sure, then I think svnadmin imported a bunch of stuff, but was unable to create the top level dir, so it probably left a bunch of orphaned crap in the repo. The load process seems pretty half baked, so be careful 🙂


Samson pointed out this PHP bug report to me:


It is an entertaining read. This illustrates a couple of problems with PHP that make me wary of using it for anything too serious. They seem to have a flagrant disregard for specification of their API, as well as backward compatibility. Additionally, the lack of strong typing appears to be the source of all of their issues. I’m not going to say weak typing is bad, I just find strong typing forces the programmer to resolve issues at compile time instead of at runtime (i.e. before the end user is actually running the code and the app blows up on them).

All of this culminates into this bug report, which erupts into a flame war, uncovering the underlying big egos that have probably led to the feeling that strict specification is unnecessary and developers can just “deal with” changes in the API in minor releases. Both of the PHP developers involved in the conversation were extremely unprofessional and resorted to such tactics as name dropping to argue their case.

It sucks, because I think PHP would be pretty nice if they were just a little more strict and professional about these things (both the technical and personal issues).

X Windows

Recently, I have heard several references to the term “X Windows”. For all of you uninformed fools out there, here’s the official word straight from the horse’s mouth (see man X):

The X.Org Foundation requests that the following names be used when referring to this software:

X Window System
X Version 11
X Window System, Version 11

So, as you can see, there is no reference to “X Windows”. It has nothing to do with “Windows”, so don’t call it that.

Sometimes I feel like constructors should be removed from Java

Sometimes constructors in Java are convenient. You can instantiate your class with all the data you need with a simple one-liner:

Car car = new Car(numberOfWheels, color, engine, doors);

That code is fairly readable and concise, but things can quickly spiral out of control. Unless you use really descriptive variable names like those above, it’s pretty easy to get lost. Eventually you end up with code like this (partially obfuscated to protect the innocent):

foo = new Bar(rs.getString(1),
(“Y”.equals(rs.getString(13)) ? true : false),
(“Y”.equals(rs.getString(14)) ? true : false),
(“Y”.equals(rs.getString(15)) ? true : false),
(“Y”.equals(rs.getString(16)) ? true : false),
(“Y”.equals(rs.getString(17)) ? true : false),
(“Y”.equals(rs.getString(18)) ? true : false),
(“Y”.equals(rs.getString(19)) ? true : false),

This is the point where I say you gotta just use a blank constructor and setter methods. Much more readable. And on a side note, when you are typing rs.getString(24), you should probably start thinking about how it might be more readable if you refer to your result set columns by name. That is all.

Ditch MySQL now

MySQL was “bought” by Sun last year, as you may know. The fact that this is significant sort of illustrates one of the reasons I didn’t like MySQL from the moment I met it in 1997 or so. It’s only like half in the game as far as being free and open source. It is tied way too much to MySQL AB, the company, and the way it is licensed is totally shady. Anyway, now Sun is dying and Larry Ellison is about to scoop it up. Monty, the MySQL guy is whining to the Internet, trying to get the European Commission to block the deal. It’s a sad story, but if Oracle doesn’t buy Sun, they will just need to get bought by someone else or go out of business. The real sad part of the story is the death of Sun, one of the original great Internet companies (my other favorite being SGI which met its fate years ago). In any case, MySQL’s future is dark and cloudy.

That is why I’m just going to go ahead and plug my favorite database, PostgreSQL. You should check it out, it’s awesome. It is way more powerful than MySQL and the licensing is better. It was built from the ground up to be a real database, not some tinkering project like MySQL. If you are running a project, especially an open source one, that is dependent on a database, you should take a serious look at PostgreSQL and consider making it your database of choice.

Always name your constraints in Oracle

In Oracle, when you create a constraint (like a primary key), you can either provide a name or have Oracle generate one for you. I got lazy on a recent project, and had Oracle generate the constraint names for the primary keys on my new tables. Later, I had to come back and change the key structure and it bit me. What I like to do is keep a set of DDL files in my project to update the database schema as it evolves. When you want to change the structure, you create a new DDL file and put in your ALTER TABLE statements. You apply it to the dev database, then when you are satisfied, you apply it to QA and eventually production. This may vary depending how many environments you have, but the idea is a consistent set of database updates across environments.

Anyway, today I had to drop the primary keys and create new ones, so I ended up with statements like this:


As you can see, the DDL is then dependent on the runtime state of the Oracle database at the time the original PK was added. This sucks, because it will end up with a different name in each environment. So, in the new PK, I gave it a name (CRITICAL_COURSE_REQUIREMENT_PK) which will be consistent across environments next time I need to change it.

A recipe for trouble

Dear the Internet,

Please never write this code:

if (value == null || value.equals(“”)) {
d = new Date(0);
} else {

This is what I like to call “bug hiding”. Rarely does a person really mean 12/31/1969 when they pass you a null or blank value. That is all.

JSP is still really bad

I had to do some maintenance work recently on a JSP app. Normally, I avoid JSP like the plague because my (dated) experience with it has been mostly bad. The app I had to maintain was a stone age thing full of scriptlets, but I did a little research and used JSTL to do some of the work on the updates. I was pretty impressed with how cleanly you can do some flow control stuff now. So, I started some new development on a new project with JSP as a proof of concept to see if it is a tolerable programming environment now. It isn’t. For the real basics, there has been a lot of improvement, but some of the mechanisms for taglibs, dealing with variable between servlet/JSP, etc. are still very clunky. And today I encountered this. If you forget to put the return type when defining a function within your app, you get a super mysterious error.

I guess you could blame the implementation (Jasper), but what does anyone else use? Also, you can sort of tell from the screen shot of the editor, but the JSP editor in the current version of Eclipse is pretty awful. It displays some of your double quotes as single quotes, which is really awkward.


Here’s a good example of some bad user interface design in my favorite IDE.

I know the Maven stuff is a plugin, so I’m guessing NetBeans allows plugins to install tabs under “Miscellaneous”. So what you end up with is a configuration screen that looks simple until you find out that there are really supposed to be 30 tabs instead of 7, but they are hiding out in the Miscellaneous section.