I have some files stored in a database blob column in Oracle 9.
I would like to have those files stored in the file system.
This should be pretty easy, but I don't find the right snipped.
How can I do this in java?
PreparedStatement ptmst = ...
ResutlSet rs = pstmt.executeQuer();
rs.getBlob();
// mistery
FileOutputStream out = new FileOutputStream();
out.write(); // etc et c
I know it should be something like that... what I don't know is what is commented as mistery
Thanks
EDIT
I finally got this derived from David's question.
This is my lazy implementation:
PreparedStatement pstmt = connection.prepareStatement("select BINARY from MYTABLE");
ResultSet rs = pstmt.executeQuery();
while( rs.next() ) {
Blob blob = rs.getBlob("BINARY");
System.out.println("Read "+ blob.length() + " bytes ");
byte [] array = blob.getBytes( 1, ( int ) blob.length() );
File file = File.createTempFile("something-", ".binary", new File("."));
FileOutputStream out = new FileOutputStream( file );
out.write( array );
out.close();
}