Using InputStream and OutputStream updating BLOB in database [message #533460] |
Wed, 30 November 2011 02:09 |
|
wtfn00b
Messages: 115 Registered: October 2011 Location: Latvia
|
Senior Member |
|
|
Good day, I hope this is the right place to post this.
I have little code that's don't really works.
InputStream is = null;
OutputStream os = null;
Connection conn = null;
Blob value = null;
PreparedStatement stmt =
conn.prepareStatement("SELECT attachment FROM user.table WHERE id = 1");
stmt.setBigDecimal(1, idValue);
ResultSet rs2 = stmt.executeQuery();
while(rs2.next()) {
value = rs2.getBlob("attachment");
}
is = data.getInputStream();
os = value.setBinaryStream(0L);
byte[] buffer = new byte[2048];
int i;
while((i = is.read(buffer)) > -1) {
os.write(buffer, 0, i);
}
I know that there is 90% of Java code.
But I have few questions:
I know that I can insert date useing INSERT. But is it possible that I can use SELECT and JAVA will know that it need to update the SELECTED column ?
Best regards,
wtfn00b.
|
|
|
|
|
|
|
|
|