How do I avoid this SQL exception?-Collection of common programming errors

This is (essentially) the old checked exceptions argument – some people love them, some people hate them (see here).

I, for one, don’t like checked exceptions (Is it dangerous to disagree with Mr. Skeet @ 415k reputation??!), so when I’m forced to deal with one, I generally use a try/catch and rethrow the error as a custom made subclass of RuntimeException. RuntimeExceptions don’t need to be handled explicitly.

Spring, which is one of the most heavily used frameworks around, takes this approach.

When you use RuntimeExceptions, though, make sure that at some point you know where that exception is going to be handled. You never want it to go all the way to your end user and let them see a nasty stack trace.