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.





This e-Mail may contain proprietary and confidential information and is sent for the 
intended recipient(s) only.
If by an addressing or transmission error this mail has been misdirected to you, you 
are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, 
copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment 
other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

Reply via email to