I was dealing with an application that stores image binary data in DB2. DB2 tooling (e.g. IBM Data Studio) didn’t seem to offer a convenient way of extracting images out of the box. I wasn’t suprised. It turns out dragging them out via JDBC was the path of least resistance.

Ensure that you give your JDBC driver enough hints about the heavy nature of the result set that is coming back. For DB2 ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY worked well.

A Windows batch script to drive the program: