ResultSet rs = con.createStatement().executeQuery( "select * from TABLE1"); rs.next(); InputStream is = rs.getBinaryStream(1);long length = rs.getBlob(1).length();rs.close();con.setAutoCommit(false); ps = con.prepareStatement("update table1 set photo = ?"); ps.setBinaryStream(1, is, length); ps.executeUpdate();
I think it's problematic to try to hold on to the stream after you've closed the ResultSet. What happens if you read the stream fully into memory (say, by copying it into a ByteArrayOutputStream), before closing the result set, and then use your in-memory byte array to provide the data for the update into the other table? thanks, bryan
