private void doDeleteUnrelated() throws SQLException {
   Connection conn = source.getConnection();
   Statement stmt = conn.createStatement();
   try {
     stmt.executeUpdate(
         "delete from THUMBNAILS where DIGOBJEKTID not in (select ID from DIGOBJEKT)");
   } finally {
     SQLQuery.tryClose(stmt);
   }
 }
 private IterableResult<Thumbnail> doFindMissing() throws SQLException {
   Connection conn = source.getConnection();
   Statement stmt = conn.createStatement();
   ResultSet rs = null;
   try {
     rs = stmt.executeQuery(SQLQuery.getFindMissingThumbnails());
     return new ThumbnailResult(rs, stmt);
   } finally {
     if (rs == null) {
       SQLQuery.tryClose(stmt);
     }
   }
 }
 private void doInsert(BigDecimal digiObjId, String mimeType, byte[] contents)
     throws SQLException {
   Connection conn = source.getConnection();
   PreparedStatement pstmt =
       conn.prepareStatement(
           "insert into THUMBNAILS (DIGOBJEKTID, MIME, CONTENTS) values (?, ?, ?)");
   try {
     pstmt.setBigDecimal(1, digiObjId);
     pstmt.setString(2, mimeType);
     pstmt.setBytes(3, contents);
     pstmt.executeUpdate();
   } finally {
     SQLQuery.tryClose(pstmt);
   }
 }