private void runGetBLOB() { try { // Prepare a Statement: PreparedStatement stmnt = conn.prepareStatement("select
aBlob from BlobTable"); // Execute ResultSet rs = stmnt.executeQuery(); while(rs.next()) { try { // Get as a BLOB Blob aBlob = rs.getBlob(1); byte[] allBytesInBlob = aBlob.getBytes(1, (int) aBlob.length()); } catch(Exception ex) { // The driver could not handle this as a BLOB... // Fallback to default (and slower) byte[] handling byte[] bytes = rs.getBytes(1); } } // Close resources rs.close(); stmnt.close(); } catch(Exception ex) { this.log("Error when trying to read BLOB: " + ex); } }