I thought I had a great idea. I could extract all of my SQL execution code into one class, and pass that class a connection, a String SQL statement with '?'s marking the parameters, and an array of Java Objects, use a loop to iterate through the Objects and use PreparedStatement.setObject() to set the values from the array and I'm done, right?
Nope. PreparedStatement doesn't handle null objects. One must call PreparedStatement.setNull(). And one cannot just pass null, one must pass the java.sql.Type value for the column type for this method. But I don't know the type, because I can't get the class of a null handle.
Anybody out there figure out a good abstraction layer between Java objects and database tables? I've run into this kind of thing a couple times.
Nope. PreparedStatement doesn't handle null objects. One must call PreparedStatement.setNull(). And one cannot just pass null, one must pass the java.sql.Type value for the column type for this method. But I don't know the type, because I can't get the class of a null handle.
Anybody out there figure out a good abstraction layer between Java objects and database tables? I've run into this kind of thing a couple times.