private void write(String source, String sql_select) { BLOB document; FileInputStream in; OutputStream out; int chunk; byte[] buffer; int length; try { System.out.println(sql_select); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); conn.setAutoCommit(false); ors = (OracleResultSet) (stmt.executeQuery(sql_select)); if (ors.next()) { document = ors.getBLOB(1); in = new FileInputStream(source); out = document.getBinaryOutputStream(); chunk = document.getChunkSize(); buffer = new byte[chunk]; length = buffer.length; while ( (length = in.read(buffer)) != -1) { out.write(buffer, 0, length); } in.close(); out.close(); } conn.close(); } catch (SQLException e) { e.printStackTrace(); } catch (FileNotFoundException fileex) { fileex.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } }