Might be worth checking if you can use a ConnectionPoolDataSource
that isn't wrapper by the app. server.

----- Original Message -----
From: "Shone Sadler" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 01, 2003 6:28 AM
Subject: Re: Inserting BLOB in Oracle


> If you are executing this within an application server and using a
> datasource you will often get a ClassCastException because (depending on
> the appserver/driver) the Application server does not give you direct
> access to the actual Oracle JDBC objects.  Instead you deal with wrapper
> classes that the app server uses for pooling.  I believe we had an issue
> with this at one time within Weblogic and simply used reflection to
> execute the getBinaryOutputStream(), which the wrapper class implemented
> as well. Not a perfect work around.
>
>
> Shone
>
> -----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".
>

===========================================================================
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".

Reply via email to