Here is an example from Oracle's site (you can just search for the string "mapBlob" to get to the applicable part). Notice their OutputStream is created with a cast:
OutputStream blobOutputStream = ((oracle.sql.BLOB)mapBlob).getBinaryOutputStream();
http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
Hope this helps
From: Slinkster <[EMAIL PROTECTED]> Reply-To: Slinkster <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: Inserting BLOB in Oracle Date: Fri, 28 Feb 2003 11:37:55 -0500
Its been a while since I've done this. As I recall, I declared that it was a BLOB in my weblogic CMP deployment descriptor. Then Weblogic allowed me to store any serializable class in the BLOB (I might have used a CLOB, I don't remember). For traditional BLOB like items you can user byte[] or char[]. You can also store arbitrary serializable objects this way, but if any of the method signatures changes, it will throw an exception when you retrieve it (even if the change was trivial).
JWS
-----Original Message----- From: Harpreet Mittar [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 10:17 AM To: [EMAIL PROTECTED] Subject: Re: Inserting BLOB in Oracle Importance: High
Thanx for the sample, but i have tried this.
It throws a ClassCastException exactly at the place where i try to cast java.sql.Blob to oracle.sql.BLOB Any inputs as to where i could be going wrong ?
Thanx..
"Szabolcs Nagy" <[EMAIL PROTECTED] To: <[EMAIL PROTECTED]> OLOGY.com> cc: Subject: RE: Inserting BLOB in Oracle 02/28/2003 08:38 PM
I hope, it helps you...
Szabolcs
public void saveFile(String fileName, byte[] fileContent) {
Statement stmt = null; Connection conn = null; ResultSet rset = null;
try { conn = getConnection();
stmt = conn.createStatement(); stmt.execute("insert into ATTACHEDFILES (filename, filecontent) values (' " + filename + "', EMPTY_BLOB())");
String blobTrick = "select fileContent from ATTACHEDFILES where filename = " + fileName; rset = stmt.executeQuery(blobTrick); if (rset.next()) { BLOB blob = (BLOB)rset.getBlob(1);//((OracleResultSet)rset).getBLOB(1); OutputStream out = blob.getBinaryOutputStream(); out.write(fileContent); out.close(); } } catch (Exception e) { //handle exception } finally { try { if (stmt != null) stmt.close(); } catch (Exception e) {} try { if (conn != null) conn.close(); } catch (Exception e) {} } }
Hi, It would be of great help if somebody could share sample code for inserting a BLOB into Oracle through weblogic.
Thanx and Regards, Harpreet.
==========================================================================To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
_________________________________________________________________ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".