Home » Developer & Programmer » JDeveloper, Java & XML » Using InputStream and OutputStream updating BLOB in database (11.2.0.1.0 - Production, jdeveloper 11g R2 11.1.2.1.0, Win7 Prof. 64-bit, Weblogic server)
Using InputStream and OutputStream updating BLOB in database [message #533460] Wed, 30 November 2011 02:09 Go to next message
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.
Re: Using InputStream and OutputStream updating BLOB in database [message #533463 is a reply to message #533460] Wed, 30 November 2011 02:35 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
But is it possible that I can use SELECT and JAVA will know that it need to update the SELECTED column ?

This is really not clear.
What is the relation between the SELECT and the UPDATE?
Yes your program (Java or any language) can know if it needs to update a column if this is what your application needs to implement.

Regards
Michel
Re: Using InputStream and OutputStream updating BLOB in database [message #533475 is a reply to message #533463] Wed, 30 November 2011 03:39 Go to previous messageGo to next message
wtfn00b
Messages: 115
Registered: October 2011
Location: Latvia
Senior Member
Some guy told me that I can use SELECT like INSERT in my language and it will understand that.
Told me that it's a new tehnology for INSERT.
Re: Using InputStream and OutputStream updating BLOB in database [message #533481 is a reply to message #533475] Wed, 30 November 2011 03:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What is EXACTLY your problem?
Yes you can use in the same way INSERT than SELECT, prepare the statement and execute it.
If you don't know then you have to read the documentation, this is basic JDBC.

Regards
Michel
Re: Using InputStream and OutputStream updating BLOB in database [message #533507 is a reply to message #533481] Wed, 30 November 2011 05:23 Go to previous messageGo to next message
wtfn00b
Messages: 115
Registered: October 2011
Location: Latvia
Senior Member
Can you please support with good JDBC manual, please ?

Regards,
wtfn00b.
Re: Using InputStream and OutputStream updating BLOB in database [message #533512 is a reply to message #533507] Wed, 30 November 2011 05:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
http://tahiti.oracle.com

Regards
Michel
Re: Using InputStream and OutputStream updating BLOB in database [message #533527 is a reply to message #533512] Wed, 30 November 2011 07:50 Go to previous message
wtfn00b
Messages: 115
Registered: October 2011
Location: Latvia
Senior Member
Thank you.

Regards,
wtfn00b.
Previous Topic: Problem in generating a XML document
Next Topic: Not Able to see OA framework workspace
Goto Forum:
  


Current Time: Fri Mar 29 03:33:09 CDT 2024