Created
August 2, 2012 07:08
-
-
Save alxfv/3234705 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PreparedStatement pstmt = conn.prepareStatement("update blob_table set blob = ? where id = ?"); | |
File blob = new File("/path/to/picture.png"); | |
FileInputStream in = new FileInputStream(blob); | |
// the cast to int is necessary because with JDBC 4 there is | |
// also a version of this method with a (int, long) | |
// but that is not implemented by Oracle | |
pstmt.setBinaryStream(1, in, (int)blob.length()); | |
pstmt.setInt(2, 42); // set the PK value | |
pstmt.executeUpdate(); | |
conn.commit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment