Insert Blob column in the client errors ClassCastException: oracle.sql.BLOB

Hi,
When I try to insert and commit a Blob column(picture) I am getting the following exception.
Is there any jar I need to add or any other setup I need to do to accept the BLOB column in the olite client database.
500 Internal Server Error
javax.faces.FacesException: #{backing_XXPBWorkOrderResultsCreatePGBean.saveButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.sql.BLOB
     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
     at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
Caused by: java.lang.ClassCastException: oracle.sql.BLOB
     at oracle.lite.poljdbc.LiteEmbPreparedStmt.setVal(Unknown Source)
     at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
     at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
     at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
     at oracle.lite.web.JupPreparedStatement.setObject(Unknown Source)
     at oracle.jbo.server.BaseSQLBuilderImpl.bindUpdateStatement(BaseSQLBuilderImpl.java:1765)
     at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:7345)
With regareds,
Kali.
OSSI.

Here are examples if inserting into a Blob from text, file, and retrieving a blob.
Insert into a Blob (Text)
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InsertBlob {
    public static void main(String[] args) throws FileNotFoundException {
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        String letterText = "some letter text";
        long id = 100;
        try {
            DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
            try {
                con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
            } catch (SQLException sqle) {
                sqle.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        try {
            stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, EMPTY_BLOB())");
            stmt.setLong(1, id);
            stmt.executeUpdate();
            stmt = con.prepareStatement("SELECT BLOB_DATA FROM BLOB_TABLE WHERE BLOB_ID = ? FOR UPDATE");
            stmt.setLong(1, id);
            rs = stmt.executeQuery();
            if (rs.next()) {
                try {
                    oracle.lite.poljdbc.BLOB oliteBlob = null;
                    oliteBlob = ((oracle.lite.poljdbc.OracleResultSet) rs).getBLOB(1);
                    byte[] byteLetterText = letterText.getBytes();
                    oliteBlob.putBytes(1, byteLetterText);
                    con.commit();
                } catch (ClassCastException e) {
                    e.printStackTrace();
                } finally {
                    rs = null;
                    stmt = null;
                    con.rollback();
                    con = null;
        } catch (SQLException e) {
            e.printStackTrace();
}Insert Into a Blob (File)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class InsertBlobFile {
    public static void main(String[] args) throws FileNotFoundException {
        Connection con = null;
        PreparedStatement stmt = null;
        long id = 200;
        try {
            DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
            try {
                con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
            } catch (SQLException sqle) {
                sqle.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        try {
            stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, ?)");
            stmt.setLong(1, id);
            File fBlob = new File ( "C:\\BLOB_TEST_FILE.TXT" );
            FileInputStream is = new FileInputStream ( fBlob );
            stmt.setBinaryStream (2, is, (int) fBlob.length() );
            stmt.executeUpdate();
            con.commit();
        } catch (SQLException e) {
            e.printStackTrace();
}Retrieve from Blob (Write to file)
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RetrieveBlob {
    final static int bBufLen = 32 * 1024;
    final static String outFile = "C:\\BLOB_OUTPUT_FILE.TXT";
    public static void main(String[] args) throws IOException {
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
            try {
                con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
            } catch (SQLException sqle) {
                sqle.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        try {
            stmt = con.prepareStatement("SELECT * FROM BLOB_TABLE");
            rs = stmt.executeQuery();
            while(rs.next()) {
                int id = rs.getInt(1);
                Blob value = rs.getBlob(2);
                System.out.println(id + " | " + value);
                writeBlobToFile(value);
        } catch (SQLException e) {
            e.printStackTrace();
    public static long readFromBlob(Blob blob, OutputStream out)
      throws SQLException, IOException {
        InputStream in = blob.getBinaryStream();
        int length = -1;
        long read = 0;
        byte[] buf = new byte[bBufLen];
        while ((length = in.read(buf)) > 0) {
            out.write(buf, 0, length);
            read += length;
        in.close();
        return read;
    public static long writeBlobToFile(Blob blob)
      throws IOException, SQLException {
        long wrote = 0;
        OutputStream fwriter = new FileOutputStream(outFile);
        wrote = readFromBlob(blob, fwriter);
        fwriter.close();
        return wrote;
}

Similar Messages

  • Oracle.sql.BLOB ClassCastException

    Hi everyone,
    I'm trying to put a serialized Java object into Oracle. I am following the example here: http://www.oracle.com/oramag/oracle/01-may/o31asktom.html
    Here is my code:
    String sql = "begin " +
          "insert into rdm_logs (datetime, id, machine, ip_addr, action_code, tablename, comments, " +
         "row_before, row_after)" +
          "values (sysdate, ?, ?, ?, ?, ?, ?, empty_blob(), empty_blob()) " +
          "return row_before into ?; " +
      "end;";
    CallableStatement stmt = connection.prepareCall(sql);
    stmt.setString(1, username);
    stmt.setString(2, machine);
    stmt.setString(3, ip);
    stmt.setString(4, action_code);
    stmt.setString(5, table);
    stmt.setString(6, comment);
    stmt.registerOutParameter(7, java.sql.Types.BLOB);               
    stmt.executeUpdate();               
    Object o = stmt.getBlob(7);
    // output class name here
    System.out.println(o.getClass().toString());
    // cast to oracle.sql.BLOB
    oracle.sql.BLOB blob = (BLOB) o;The system output is:
    class oracle.sql.BLOB
    java.lang.ClassCastException: oracle.sql.BLOB
    As you can see, the System.out gives oracle.sql.BLOB as the object class type, so why does it throw an exception when I cast it to be the same?
    Any help would be appreciated.

    As you can see, the System.out gives oracle.sql.BLOB as the object
    class type, so why does it throw an exception when I cast it to be the same?This can happen if the two BLOB classes have been loaded with two different unrelated class loaders. Even though the names of the classes are the same there are two separate classes.
    How to fix this depends... Somehow arrange the JDBC driver to be loaded by the system class loader before any other class loader has a chance to load it?

  • Associative array type for each blob column in the table

    i am using the code in given link
    http://www.oracle.com/technology/oramag/oracle/07-jan/o17odp.html
    i chnages that code like this
    CREATE TABLE JOBS
    JOB_ID VARCHAR2(10 BYTE),
    JOB_TITLE VARCHAR2(35 BYTE),
    MIN_SALARY NUMBER(6),
    MAX_SALARY NUMBER(6),
    JOBPIC BLOB
    CREATE OR REPLACE PACKAGE associative_array
    AS
    -- define an associative array type for each column in the jobs table
    TYPE t_job_id IS TABLE OF jobs.job_id%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_job_title IS TABLE OF jobs.job_title%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_min_salary IS TABLE OF jobs.min_salary%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_max_salary IS TABLE OF jobs.max_salary%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_jobpic IS TABLE OF jobs.jobpic%TYPE
    INDEX BY PLS_INTEGER;
    -- define the procedure that will perform the array insert
    PROCEDURE array_insert (
    p_job_id IN t_job_id,
    p_job_title IN t_job_title,
    p_min_salary IN t_min_salary,
    p_max_salary IN t_max_salary,
    p_jobpic IN t_jobpic
    END associative_array;
    CREATE OR REPLACE package body SHC_OLD.associative_array as
    -- implement the procedure that will perform the array insert
    procedure array_insert (p_job_id in t_job_id,
    p_job_title in t_job_title,
    p_min_salary in t_min_salary,
    p_max_salary in t_max_salary,
    P_JOBPIC IN T_JOBPIC
    ) is
    begin
    forall i in p_job_id.first..p_job_id.last
    insert into jobs (job_id,
    job_title,
    min_salary,
    max_salary,
    JOBPIC
    values (p_job_id(i),
    p_job_title(i),
    p_min_salary(i),
    p_max_salary(i),
    P_JOBPIC(i)
    end array_insert;
    end associative_array;
    this procedure is called from .net. from .net sending blob is posiible or not.if yes how

    Ok, that won't work...you need to generate an image tag and provide the contents of the blob column as the src for the image tag.
    If you look at my blog entry -
    http://jes.blogs.shellprompt.net/2007/05/18/apex-delivering-pages-in-3-seconds-or-less/
    and download that Whitepaper that I talk about you will find an example of how to do what you want to do. Note the majority of that whitepaper is discussing other (quite advanced) topics, but there is a small part of it that shows how to display an image stored as a blob in a table.

  • ClassCastException while inserting in oracle.sql.BLOB

    Hi,
    I have to insert a blob data in to database . I wrote the code . I'm having a ClassCastException problem in the line oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
    oracle.sql.BLOB.DURATION_CALL); while trying to store a BLOB value I'm using Oracle 9i. (JDBC classes12.jar).
    if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem .
    But when I use JBoss to run , I will get ClassCastException
    I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the jboss datasource. The code to save the BLOB is as follows:
    String sql = " update test set code = ? where id = ?  ";
                 BLOB   newBlob = BLOB.createTemporary(dbcon, false, BLOB.DURATION_CALL);
                  newBlob.putBytes(1,data.getBytes());
                  stmt = dbcon.prepareStatement(newsql);
                 stmt.setBlob(1, newBlob);
                 stmt.setInt(2, Studid );
                 stmt.executeUpdate();
                 stmt.close();Can any one tell me how can I get this code to work with the datasource implementation.
    Thanks

    I think this could be a problem with the class loader . Take a look at this thread It should solve your problem.
    http://forum.java.sun.com/thread.jspa?forumID=48&threadID=788715

  • Error while calling data service: ClassCastException: oracle.sql.TIMESTAMP

    I created a data service out of an Oracle datastore (table) which has a number of TIMESTAMP columns and deployed it in Axis2
    When testing the Web Service in Designer, I get this error and can't find any solution:
    com.sunopsis.wsinvocation.SnpsWSInvocationException: oracle.sql.TIMESTAMP cannot be cast to java.util.Date
         at com.sunopsis.wsinvocation.client.a.a.d.requestReply(d.java)
         at com.sunopsis.graphical.wsclient.f.b(f.java)
         at com.sunopsis.graphical.tools.utils.swingworker.v.call(v.java)
         at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:176)
         at com.sunopsis.graphical.tools.utils.swingworker.l.run(l.java)
         at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
         at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: oracle.sql.TIMESTAMP cannot be cast to java.util.Date
         at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
         at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
         at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
         at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
         at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
         at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149)
         at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
         at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
         at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
         at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
         at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
         at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
         at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
         at org.apache.axis.client.Call.invoke(Call.java:2767)
         at org.apache.axis.client.Call.invoke(Call.java:1792)
         at com.sunopsis.wsinvocation.client.a.a.d.a(d.java)
         ... 8 more
    Caused by:
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
    faultSubcode:
    faultString: oracle.sql.TIMESTAMP cannot be cast to java.util.Date
    faultActor:
    faultNode:
    faultDetail:
         {}stackTrace:java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.util.Date
         at com.sunopsis.data.transform.impl.DataTransformerUtilDate2SqlTimestamp.from(DataTransformerUtilDate2SqlTimestamp.java)
         at com.sunopsis.data.transform.impl.generic.DataTransformerReverser.to(DataTransformerReverser.java)
         at com.sunopsis.data.transform.impl.generic.DataTransformerIfNullThenExceptionWrapper.to(DataTransformerIfNullThenExceptionWrapper.java)
         at com.sunopsis.data.transform.impl.generic.DataTransformerCombiner.to(DataTransformerCombiner.java)
         at oracle.odi.dataservices.fwk.axis2.OMSerializer.objectToXsd(OMSerializer.java)
         at oracle.odi.dataservices.fwk.axis2.OMSerializer.serializeManagedEntity(OMSerializer.java)
         at oracle.odi.dataservices.fwk.axis2.OMSerializer.serializeManagedEntityList(OMSerializer.java)
         at oracle.odi.dataservices.fwk.axis2.OMSerializer.serializeOMElement(OMSerializer.java)
         at oracle.odi.dataservices.fwk.axis2.DataServicesMessageReceiver.invokeBusinessLogic(DataServicesMessageReceiver.java)
         at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:39)
         at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:144)
         at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:279)
         at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:116)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
         at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
         at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
         at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
         at java.lang.Thread.run(Thread.java:619)
    oracle.sql.TIMESTAMP cannot be cast to java.util.Date
         at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
         at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
         at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
         at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
         at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
         at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149)
         at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
         at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
         at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
         at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
         at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
         at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
         at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
         at org.apache.axis.client.Call.invoke(Call.java:2767)
         at org.apache.axis.client.Call.invoke(Call.java:1792)
         at com.sunopsis.wsinvocation.client.a.a.d.a(d.java)
         at com.sunopsis.wsinvocation.client.a.a.d.requestReply(d.java)
         at com.sunopsis.graphical.wsclient.f.b(f.java)
         at com.sunopsis.graphical.tools.utils.swingworker.v.call(v.java)
         at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:176)
         at com.sunopsis.graphical.tools.utils.swingworker.l.run(l.java)
         at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
         at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
         at java.lang.Thread.run(Thread.java:534)

    What database are you doing this with?
    B

  • Oracle.sql.BLOB.setBytes() Error

    Hi,
    I'm trying to use Java to put a large array of bytes into a BLOB table column. I'm first inserting the new row with an empty_blob() and then calling select <blob_column> ... for update and getting the oracle.sql.BLOB out of the resultset. I then try to call setBytes() on this BLOB and I get the following exception:
    java.sql.SQLException: Invalid argument(s) in call: putBytes()
    at oracle.jdbc.driver.T4CConnection.putBytes(T4CConnection.java:2440)
    at oracle.sql.BLOB.setBytes(BLOB.java:916)
    I'm using Oracle XE (oracle-xe-11.2.0-1.0.x86_64.rpm), the latest ojdbc6.jar, and jboss 4.2.2 on CentOS.
    A code snippet of what I'm doing:
    ... stmt = con.prepareStatement("select blob_column from blob_table where id=? for update"); stmt.setLong(1, Id); ResultSet rs = stmt.executeQuery(); try {     if (rs.next()) {         WrappedResultSet wrappedRs = (WrappedResultSet)rs;         BLOB oracleBlob = ((OracleResultSet)wrappedRs.getUnderlyingResultSet()).getBLOB(1);         if(oracleBlob != null) {             byte[] bytes = getData();             int pos = 0;             long bytesLeft = bytes.length;             log.debug("Attempting to write " + bytes.length + " bytes to BLOB");             while(bytesLeft > 0) {                 int bytesWritten = oracleBlob.setBytes(pos, bytes, pos, MAXBUFSIZE);                 log.debug("Wrote " + bytesWritten + " bytes to BLOB");                 bytesLeft -= bytesWritten;                 pos += bytesWritten;             }         }     } } finally {     rs.close(); } ...
    Any help would be greatly appreciated!

    Welcome to the forum!
    Thanks for posting the code and the DB, JDBC and app server versions. Those are what is needed to help.
    >
    java.sql.SQLException: Invalid argument(s) in call: putBytes()
                while(bytesLeft > 0) {
                    int bytesWritten = oracleBlob.setBytes(pos, bytes, pos, MAXBUFSIZE);
                    log.debug("Wrote " + bytesWritten + " bytes to BLOB");
                    bytesLeft -= bytesWritten;
                    pos += bytesWritten;That 'Invalid argument . . .' was your clue to look at the ARGUMENT values you are passing to the method call. You could have easily done that by displaying the values to the console each time in the loop BEFORE the method call.
    This is the signature of that method in the Javadocs (edited to highlight the relevant parts):
    http://docs.oracle.com/javase/6/docs/api/java/sql/Blob.html#setBytes(long, byte[])
    >
    int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
    Writing starts at position pos in the BLOB value; len bytes from the given byte array are written.
    Parameters:
    pos - the position in the BLOB object at which to start writing; the first position is 1
    bytes - the array of bytes to be written to this BLOB object
    offset - the offset into the array bytes at which to start reading the bytes to be set
    len - the number of bytes to be written to the BLOB value from the array of bytes bytes
    >
    This is what you are passing for 'len': MAXBUFSIZE
    Most likely that value is LARGER than the 'byte array' that you are using; perhaps it is even the MAX int size.
    That value is invalid.
    In addition each time thru the loop you increment 'pos' and use 'pos' as the 'offset' into your array. Then you once again use MAXBUFSIZE as the number of bytes to write from your array. Even if MAXBUFSIZE is less than the length of your array at some point it will likely be greater than what is left of the array.
    For example, if MAXBUFSIZE is 2 and your array length is 3 the first 'put' will put the first two bytes. Then the second put will use a 'pos' of 2 and try to put 2 more bytes; except there is only one byte left.
    Your code updates the entire BLOB value. Best practices are to use the stream methods for reading and writing BLOB/CLOB rather than the 'setBytes' method you are using. The main reason for this is performance: the stream methods write DIRECTLY to the database.
    >
    Notes:
    The stream write methods described in this section write directly to the database when you write to the output stream. You do not need to run an UPDATE to write the data. However, you need to call close or flush to ensure all changes are written. CLOBs and BLOBs are transaction controlled. After writing to either, you must commit the transaction for the changes to be permanent.
    >
    See 'Reading and Writing BLOB and CLOB Data' in the JDBC Dev Guide
    http://docs.oracle.com/cd/B19306_01/java.102/b14355/oralob.htm#i1058044
    >
    Example: Writing BLOB Data
    Use the setBinaryOutputStream method of an oracle.sql.BLOB object to write BLOB data.
    The following example reads a vector of data into a byte array, then uses the setBinaryOutputStream method to write an array of character data to a BLOB.
    java.io.OutputStream outstream;
    // read data into a byte array
    byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    // write the array of binary data to a BLOB
    outstream = ((BLOB)my_blob).setBinaryOutputStream(1L);
    outstream.write(data);

  • Get more info about the last errors in Oracle

    Hi all,
    There is a log in a live system where it is possible to see every minute the following error:
    Sweep Incident[48073]: failed, err=[1858]
    I know that error can happen mainly when:
    1. Trying to insert caracter field in a numeric column
    2. Using in the wrong way the function to_date()
    I need more information about that error, what can be causing the error in the system and why. Is it possible to see more information about the last errors in Oracle? For example, if a query produces an error... is it possible to see in Oracle the error and the query that caused the error?
    Hope you can help me.
    Thanks in advance.

    Thanks Niall.
    I'm not sure if I got you...
    What I found is that MMON makes snapshots of the database 'health' and stores this information in the AWR. So, it seems like in the database there could be a numeric column that is storing character fields, and when MMON works, it finds that error... is that right?
    I found the following information:
    SQL> select substr(s.username,1,18) username,
    2 substr(s.program,1,22) program,
    3 decode(s.command,
    4 0,'No Command',
    5 1,'Create Table',
    6 2,'Insert',
    7 3,'Select',
    8 6,'Update',
    9 7,'Delete',
    10 9,'Create Index',
    11 15,'Alter Table',
    12 21,'Create View',
    13 23,'Validate Index',
    14 35,'Alter Database',
    15 39,'Create Tablespace',
    16 41,'Drop Tablespace',
    17 40,'Alter Tablespace',
    18 53,'Drop User',
    19 62,'Analyze Table',
    20 63,'Analyze Index',
    21 s.command||': Other') command
    22 from
    23 v$session s,
    24 v$process p,
    25 v$transaction t,
    26 v$rollstat r,
    27 v$rollname n
    28 where s.paddr = p.addr
    29 and s.taddr = t.addr (+)
    30 and t.xidusn = r.usn (+)
    31 and r.usn = n.usn (+)
    32 order by 1;
    USERNAME PROGRAM COMMAND
    oracle@airvs1b (MMON) No Command
    SQL> select addr, pid, spid, username, serial#, program,traceid, background, latchwait, latchspin from v$process where program='oracle@airvs1b (MMON)';
    ADDR PID SPID USERNAME SERIAL# PROGRAM
    000000044A4E48A8 24 15372 oracle 1 oracle@airvs1b (MMON)
    TRACEID B LATCHWAIT LATCHSPIN
    ---------------- ---------- ------------------------ --------------- 1
    SQL> select
    2 substr(a.spid,1,9) pid,
    3 substr(b.sid,1,5) sid,
    4 substr(b.serial#,1,5) ser#,
    5 substr(b.machine,1,6) box,
    6 substr(b.username,1,10) username,
    7 b.server,
    8 substr(b.osuser,1,8) os_user,
    9 substr(b.program,1,40) program
    10 from v$session b, v$process a
    11 where
    12 b.paddr = a.addr
    13 and a.spid=15372
    14 order by spid;
    PID SID SER# BOX USERNAME SERVER OS_USER PROGRAM
    15372 1082 1 airvs1 DEDICATED oracle oracle@airvs1b (MMON)
    Is there any way I can see what MMON is doing and when is failing?
    Thank you very much.
    Edited by: user11281526 on 19-jun-2009 5:18

  • ClassCastException in oracle.sql.BLOB.createTemporary

    Hi,
    I'm having a ClassCastException problem using the method oracle.sql.BLOB.createTemporary while trying to store a BLOB value (JDBC classes12.jar). The problem is quite clear - if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem - if I use it with an Orion datasource shipped with Oracle IAS10g it gives me a ClassCastException. I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the Orion datasource. The code to save the BLOB is as follows:
    oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
    oracle.sql.BLOB.DURATION_SESSION);
    blob.open(BLOB.MODE_READWRITE);
    OutputStream out = blob.getBinaryOutputStream();
    try {
    out.write((byte[])value);
    out.flush();
    out.close();
    } catch (IOException e) {
    throw new SQLException("failed write to blob" + e.getMessage());
    blob.close();
    ((oracle.jdbc.OraclePreparedStatement)(st)).setBLOB(index, blob);
    My questions are:
    (1) is it possibile to save a BLOB type with a different version of Oracle JDBC without having to rely on the Oracle specific implementation of the JDBC interface (the cast of the PreparedStatement to oracle.jdbc.OraclePreparedStatement is quite ugly and not very portable!).
    (2) if not, then how can I get this code to work with the datasource implementation for Oracle IAS.
    thanks in advance for any help.
    Dara.

    If you are using OCI driver, you may check whether using thin driver would avoid ClassCastException.

  • Oracle.sql.BLOB.freeTemporary() is not freeing TEMP space in the database

    Hi Folks,
    We are using oracle.sql.BLOB to store some file information into the database.
    Allocation of the temp space is done as below
    BLOB blob=BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION); // this results in the usage of TEMP space from database
    And subsequent release is done as below
    blob.freeTemporary(); // this should have release the space from the database.
    This is on Oracle 10g, Java 1.6, ojdbc6.jar There are no exceptions. Even a simple program results in the same.
    Anybody faced something similar? Any pointers would be really appreciated.
    Thanks,
    Deva
    Edited by: user10728663 on Oct 11, 2011 5:33 AM

    Thanks a lot for the information.
    Memory is fine. And I am able to reproduce this within the scope of a simple example as well.
    Would you have any reference to the thread which had earlier reported this as a bug. I tried a reasonable amount of search in the forum, but no success.
    Thanks very much for any pointers.

  • Javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB

    Hi there,
    I'm facing this exception.
    My code:
    final ReportTemplateAttachment rta = new ReportTemplateAttachment();
    FileBlob fb = new FileBlob();
    fb.setContentType(attachmentDto.getContentType().getValue());
    fb.setCreationDate(sysDate);
    fb.setCreationUser(userId);
    final SerialBlob blob = new SerialBlob(attachmentDto.getFileVal());//it's a  byte[]
    //SerialBlob is of type javax.sql.rowset.serial.SerialBlob
    fb.setFileData(blob);
    fb.setName(attachmentDto.getFileName());
    fb.setLastUpdateDate(sysDate);
    fb.setLastUpdateUser(userId);
    fb.setLength(blob.length());
    rta.setFileBlob(fb);and the object rta will be inserted into another object.
    The variable of interest in FileBlob hbm is defined as follows:
    <property name="fileData" type="blob">
                <column name="FILE_DATA" />
    </property>where the type blob is oracle.sql.BLOB
    If I change the oracle.sql.BLOB to javax.sql.rowset.serial.SerialBlob in the hbm, I can insert but when I try to get the blob back I get a deserialize exception so this change is not an option.
    but when I save the main Object (a cascade operation) I get the following exception:
    org.springframework.jdbc.UncategorizedSQLException:
    Hibernate flushing: could not insert: [pt.sc.data.entities.FileBlob];
    uncategorized SQLException for SQL
    [insert into WP_ADMIN.file_blob (name, content_type, length, file_data, status, creation_user, creation_date, last_update_user, last_update_date, id)
    values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)];
    SQL state [null];
    error code [0];
    An SQLException was provoked by the following failure: java.lang.ClassCastException:
    javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB;
    nested exception is java.sql.SQLException: An SQLException was provoked by the following failure:
    java.lang.ClassCastException: javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOBAny light on the subject?
    Thanks in advance,
    mleiria

    You don't seem to understand the difference between an object model and a database. Hibernate, being an ORM package, works on the object model and will, based on what you request it to do, generate proper SQL statements to get the database part going. But you shouldn't be thinking about databases when using Hibernate; your main focus is the object model. There is no blob, only binary data. Binary data in Java is generally handled through a byte array.
    If you want to think in databases where blobs do exist, you should be using JDBC directly, not Hibernate.
    (I'm far from being an expert in Hibernate)I would really suggest taking a few hours and reading through the manual. You don't need to be an expert but you should at least know what kind of tool you're working with.

  • NullPointerException at oracle.sql.BLOB.createTemporary(BLOB.java:590)

    Hi,
    I seldom use the BLOB. Here is the coding that creates a BLOB.
    private  BLOB getBlob(byte[] str, Connection con) throws SQLException, IOException {
      BLOB blob = BLOB.createTemporary(con, true, BLOB.DURATION_SESSION);
      blob.open(BLOB.MODE_READWRITE);
      OutputStream writer = blob.getBinaryOutputStream();
      writer.write(str);
      writer.flush();
      writer.close();
      blob.close();
      return blob;
    After inserting this BLOB into database table via ojdbc, BLOB.freeTemporary() is called.
         BLOB blob = getBlob(compressedClaim,connStore);
         rsImagePstmt.setObject(4,blob);
         rsImagePstmt.executeUpdate();
         BLOB.freeTemporary( blob );
    Sometimes it's running ok and finished properly. Sometimes I got the following exception after running 2.5 hours.
    Thanks a lot for any suggestion and help.  We use oracle 10.2 and java1.4 library here.
                                      > Exception: java.lang.NullPointerException
                                      >                           at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:669)
                                      >                           at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:602)
                                      >                           at oracle.jdbc.driver.T2CConnection.createTemporaryBlob(T2CConnection.java:2039)
                                      >                           at oracle.sql.BLOB.createTemporary(BLOB.java:590)
    If I ran in the debug mode, I got the following errors after 2.5 hours:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x62F0BCF4
    Function=Java_oracle_jdbc_driver_T2CStatement_t2cFetchDmlReturnParams+0x594
    Library=C:\oracle\product\10.2.0\client\BIN\ocijdbc10.dll
    Current Java thread:
      at oracle.jdbc.driver.T2CConnection.lobCreateTemporary(Native Method)
      at oracle.jdbc.driver.T2CConnection.createTemporaryBlob(T2CConnection.java:2039)
      at oracle.sql.BLOB.createTemporary(BLOB.java:590)
      at com.viant.consumer.impl.RateSheetConsumer.getBlob(RateSheetConsumer.java:386)
      at com.viant.consumer.impl.RateSheetConsumer.finishRateSheet(RateSheetConsumer.java:293)
      at com.viant.consumer.impl.RateSheetConsumer.run(RateSheetConsumer.java:156)
      at java.lang.Thread.run(Thread.java:534)
    Dynamic libraries:
    0x00400000 - 0x0040B000  C:\jdk1.4\bin\javaw.exe
    0x77220000 - 0x7735C000  C:\Windows\SYSTEM32\ntdll.dll
    0x76CE0000 - 0x76DB4000  C:\Windows\system32\kernel32.dll
    0x75620000 - 0x7566B000  C:\Windows\system32\KERNELBASE.dll
    0x758D0000 - 0x75970000  C:\Windows\system32\ADVAPI32.dll
    0x75C10000 - 0x75CBC000  C:\Windows\system32\msvcrt.dll
    0x75B20000 - 0x75B39000  C:\Windows\SYSTEM32\sechost.dll
    0x77170000 - 0x77211000  C:\Windows\system32\RPCRT4.dll
    0x75B40000 - 0x75C09000  C:\Windows\system32\USER32.dll
    0x75D50000 - 0x75D9E000  C:\Windows\system32\GDI32.dll
    0x77440000 - 0x7744A000  C:\Windows\system32\LPK.dll
    0x76F90000 - 0x7702D000  C:\Windows\system32\USP10.dll
    0x77360000 - 0x7737F000  C:\Windows\system32\IMM32.DLL
    0x75A00000 - 0x75ACC000  C:\Windows\system32\MSCTF.dll
    0x62A20000 - 0x62A2C000  C:\PROGRA~1\NETINST\NIAMH.DLL
    0x75330000 - 0x75368000  C:\PROGRA~1\SOPHOS\SOPHOS~1\SOPHOS~1.DLL
    0x77420000 - 0x77425000  C:\Windows\system32\PSAPI.DLL
    0x752B0000 - 0x752C5000  C:\Windows\system32\AMINIT32.DLL
    0x08000000 - 0x08139000  C:\jdk1.4\jre\bin\client\jvm.dll
    0x73510000 - 0x73542000  C:\Windows\system32\WINMM.dll
    0x75210000 - 0x7525C000  C:\Windows\system32\apphelp.dll
    0x10000000 - 0x10007000  C:\jdk1.4\jre\bin\hpi.dll
    0x00270000 - 0x0027E000  C:\jdk1.4\jre\bin\verify.dll
    0x00280000 - 0x00299000  C:\jdk1.4\jre\bin\java.dll
    0x002A0000 - 0x002AD000  C:\jdk1.4\jre\bin\zip.dll
    0x003D0000 - 0x003EC000  C:\jdk1.4\jre\bin\jdwp.dll
    0x002B0000 - 0x002B5000  C:\jdk1.4\jre\bin\dt_socket.dll
    0x773E0000 - 0x77415000  C:\Windows\system32\ws2_32.dll
    0x75970000 - 0x75976000  C:\Windows\system32\NSI.dll
    0x736D0000 - 0x736E0000  C:\Windows\system32\NLAapi.dll
    0x71BE0000 - 0x71BF0000  C:\Windows\system32\napinsp.dll
    0x71BA0000 - 0x71BB2000  C:\Windows\system32\pnrpnsp.dll
    0x74D50000 - 0x74D8C000  C:\Windows\System32\mswsock.dll
    0x74C10000 - 0x74C54000  C:\Windows\system32\DNSAPI.dll
    0x71BF0000 - 0x71BF8000  C:\Windows\System32\winrnr.dll
    0x71C30000 - 0x71C57000  C:\Program Files\Common Files\Microsoft Shared\Windows Live\WLIDNSP.DLL
    0x75DA0000 - 0x75DF7000  C:\Windows\system32\SHLWAPI.dll
    0x74370000 - 0x7438C000  C:\Windows\system32\IPHLPAPI.DLL
    0x74820000 - 0x74827000  C:\Windows\system32\WINNSI.DLL
    0x721E0000 - 0x72218000  C:\Windows\System32\fwpuclnt.dll
    0x71C20000 - 0x71C26000  C:\Windows\system32\rasadhlp.dll
    0x74840000 - 0x74857000  C:\ProgramData\Sophos\Web Intelligence\swi_ifslsp.dll
    0x74830000 - 0x74839000  C:\Windows\system32\VERSION.dll
    0x76090000 - 0x76CDB000  C:\Windows\system32\SHELL32.dll
    0x74810000 - 0x74815000  C:\Windows\System32\wshtcpip.dll
    0x01240000 - 0x0124F000  C:\jdk1.4\jre\bin\net.dll
    0x62F00000 - 0x62F13000  C:\oracle\product\10.2.0\client\BIN\ocijdbc10.dll
    0x08450000 - 0x084A9000  C:\oracle\product\10.2.0\client\bin\OCI.dll
    0x7C340000 - 0x7C396000  C:\Windows\system32\MSVCR71.dll
    0x61C20000 - 0x61E77000  C:\oracle\product\10.2.0\client\bin\OraClient10.Dll
    0x60870000 - 0x60956000  C:\oracle\product\10.2.0\client\bin\oracore10.dll
    0x60A80000 - 0x60B47000  C:\oracle\product\10.2.0\client\bin\oranls10.dll
    0x63690000 - 0x636A8000  C:\oracle\product\10.2.0\client\bin\oraunls10.dll
    0x60EB0000 - 0x60EB7000  C:\oracle\product\10.2.0\client\bin\orauts.dll
    0x75770000 - 0x758CC000  C:\Windows\system32\ole32.dll
    0x636B0000 - 0x636B6000  C:\oracle\product\10.2.0\client\bin\oravsn10.dll
    0x60FA0000 - 0x61098000  C:\oracle\product\10.2.0\client\bin\oracommon10.dll
    0x63430000 - 0x63457000  C:\oracle\product\10.2.0\client\bin\orasnls10.dll
    0x08C40000 - 0x091B8000  C:\oracle\product\10.2.0\client\bin\orageneric10.dll
    0x091C0000 - 0x09337000  C:\oracle\product\10.2.0\client\bin\oraxml10.dll
    0x014F0000 - 0x01501000  C:\Windows\system32\MSVCIRT.dll
    0x60960000 - 0x60A77000  C:\oracle\product\10.2.0\client\bin\oran10.dll
    0x62740000 - 0x62780000  C:\oracle\product\10.2.0\client\bin\oranl10.dll
    0x62790000 - 0x627A8000  C:\oracle\product\10.2.0\client\bin\oranldap10.dll
    0x627F0000 - 0x628FD000  C:\oracle\product\10.2.0\client\bin\orannzsbb10.dll
    0x62530000 - 0x62583000  C:\oracle\product\10.2.0\client\bin\oraldapclnt10.dll
    0x62670000 - 0x6268B000  C:\oracle\product\10.2.0\client\bin\orancrypt10.dll
    0x71230000 - 0x71237000  C:\Windows\system32\WSOCK32.dll
    0x75CC0000 - 0x75D4F000  C:\Windows\system32\OLEAUT32.dll
    0x62920000 - 0x6296D000  C:\oracle\product\10.2.0\client\bin\oranro10.dll
    0x626B0000 - 0x626B7000  C:\oracle\product\10.2.0\client\bin\oranhost10.dll
    0x62660000 - 0x62666000  C:\oracle\product\10.2.0\client\bin\orancds10.dll
    0x629C0000 - 0x629C8000  C:\oracle\product\10.2.0\client\bin\orantns10.dll
    0x09340000 - 0x096B5000  C:\oracle\product\10.2.0\client\bin\orapls10.dll
    0x07B80000 - 0x07B89000  C:\oracle\product\10.2.0\client\bin\oraslax10.dll
    0x63080000 - 0x63285000  C:\oracle\product\10.2.0\client\bin\oraplp10.dll
    0x61ED0000 - 0x61F68000  C:\oracle\product\10.2.0\client\bin\orahasgen10.dll
    0x62AB0000 - 0x62B24000  C:\oracle\product\10.2.0\client\bin\oraocr10.dll
    0x084B0000 - 0x084F9000  C:\oracle\product\10.2.0\client\bin\oraocrb10.dll
    0x73860000 - 0x73871000  C:\Windows\system32\NETAPI32.dll
    0x74B00000 - 0x74B09000  C:\Windows\system32\netutils.dll
    0x74F80000 - 0x74F99000  C:\Windows\system32\srvcli.dll
    0x73850000 - 0x7385F000  C:\Windows\system32\wkscli.dll
    0x73840000 - 0x7384F000  C:\Windows\system32\SAMCLI.DLL
    0x74BE0000 - 0x74C02000  C:\Windows\system32\LOGONCLI.DLL
    0x62980000 - 0x62991000  C:\oracle\product\10.2.0\client\bin\orantcp10.dll
    0x63520000 - 0x635BB000  C:\oracle\product\10.2.0\client\bin\orasql10.dll
    0x751E0000 - 0x751FB000  C:\Windows\system32\SspiCli.dll
    0x70890000 - 0x7089B000  C:\Windows\system32\cscapi.dll
    0x75290000 - 0x7529C000  C:\Windows\system32\CRYPTBASE.dll
    0x740B0000 - 0x740F0000  C:\Windows\system32\uxtheme.dll
    0x09B80000 - 0x09C92000  C:\jdk1.4\jre\bin\awt.dll
    0x72870000 - 0x728C1000  C:\Windows\system32\WINSPOOL.DRV
    0x09810000 - 0x09861000  C:\jdk1.4\jre\bin\fontmanager.dll
    0x0ACF0000 - 0x0ADD7000  C:\Windows\system32\ddraw.dll
    0x73AA0000 - 0x73AA6000  C:\Windows\system32\DCIMAN32.dll
    0x76DF0000 - 0x76F8D000  C:\Windows\system32\SETUPAPI.dll
    0x753F0000 - 0x75417000  C:\Windows\system32\CFGMGR32.dll
    0x75450000 - 0x75462000  C:\Windows\system32\DEVOBJ.dll
    0x73C80000 - 0x73C93000  C:\Windows\system32\dwmapi.dll
    0x0ADE0000 - 0x0AE71000  C:\Windows\system32\igdumdx32.dll
    0x0AF10000 - 0x0B3E1000  C:\Windows\system32\igdumd32.dll
    0x742C0000 - 0x742E5000  C:\Windows\system32\PowrProf.dll
    0x66150000 - 0x6621C000  C:\Windows\system32\D3DIM700.DLL
    0x76DC0000 - 0x76DEA000  C:\Windows\system32\imagehlp.dll
    0x70BF0000 - 0x70CDB000  C:\Windows\system32\dbghelp.dll
    Heap at VM Abort:
    Heap
      def new generation   total 4608K, used 291K [0x10010000, 0x10510000, 0x12770000)
       eden space 4096K,   5% used [0x10010000, 0x10046aa0, 0x10410000)
       from space 512K,  14% used [0x10490000, 0x104a2208, 0x10510000)
       to   space 512K,   0% used [0x10410000, 0x10410000, 0x10490000)
      tenured generation   total 60544K, used 56437K [0x12770000, 0x16290000, 0x30010000)
        the space 60544K,  93% used [0x12770000, 0x15e8d4b8, 0x15e8d600, 0x16290000)
      compacting perm gen  total 12800K, used 12682K [0x30010000, 0x30c90000, 0x34010000)
        the space 12800K,  99% used [0x30010000, 0x30c72900, 0x30c72a00, 0x30c90000)
    Local Time = Thu Oct 17 11:29:35 2013
    Elapsed Time = 9003
    # The exception above was detected in native code outside the VM

    Hi!
    It seems you can do this:
              try {
                   conn = new OracleDriver().defaultConnection();                graphblob = oracle.sql.BLOB.createTemporary(conn, false,oracle.sql.BLOB.DURATION_CALL); // must init
                   System.out.println("Blob is init");
              } catch ( java.sql.SQLException sEx ) {
                   throw new RuntimeException ("No connection", sEx);
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1285601748584
    http://www.unix.org.ua/orelly/oracle/guide8i/ch09_08.htm
    /Bjoern

  • Oracle.sql.BLOB array

    Hi,
    I have a database table(say MY_BLOB_TABLE.) having one blob column
    I want to send each blob column as an attachment to a single email i.e. I for a particular case if I have 10 qualifying rows in MY_BLOB_TABLE,I want to send all these 10 blobs as different attachments with a SINGLE email.
    I have the working code (from asktom) that allows me to send one attchment per email ..so I changed the code so that it takes array types to the things..
    here is my code:
    Database Type:
    create or replace type xx_blobdata is varray(50) of blob;
    create or replace type xx_attachedfile is varray(50) of varchar2(1000);
    create or replace type xx_attachedfiletype is varray(50) of varchar2(1000);
    Java Code
    public class xx_attachments_mail
    static String dftMime = "application/octet-stream";
    static String dftName = "filename.dat";
    public static oracle.sql.NUMBER
    send(String from,
    String to,
    String cc,
    String bcc,
    String subject,
    String body,
    String SMTPHost,
    oracle.sql.BLOB[] attachmentData,
    String[] attachmentType,
    String[] attachmentFileName);
    PLSQL Wrapper
    create or replace function xx_attachments_mail_send(
    p_from in varchar2,
    p_to in varchar2,
    p_cc in varchar2,
    p_bcc in varchar2,
    p_subject in varchar2,
    p_body in varchar2,
    p_smtp_host in varchar2,
    p_attachment_data in xx_blobdata,
    p_attachment_type in xx_attachedfiletype,
    p_attachment_file_name in xx_attachedfile) return number
    as
    language java name 'xx_attachments_mail.send( java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    oracle.sql.BLOB[],
    java.lang.String[],
    java.lang.String[]
    ) return oracle.sql.NUMBER';
    Actual Call:
    attachment_data :=xx_blobdata();
    attachment_type :=xx_attachedfiletype();
    attachment_name :=xx_attachedfile();
    ret_code := xx_attachments_mail_send(
    p_from => '[email protected]',
    p_to => '[email protected]',
    p_cc => NULL,
    p_bcc => NULL,
    p_subject => 'testing',
    p_body => 'testing..',
    p_smtp_host => 'myserver.com',
    p_attachment_data => attachment_data,
    p_attachment_type => attachment_type,
    p_attachment_file_name => attachment_name);
    Everything compiles. All objects are valid in database.But when I call I get the following error:
    ORA-29531: no method send in class xx_attachments_mail
    ORA-06512: at "XX_ATTACHMENTS_MAIL_SEND", line 1
    Can anybody point out what is wrong that I am doing.
    Thanks.

    Its already there...
    public static oracle.sql.NUMBER send();
    The code works well if I remove arrays (i.e. []) ... my problem is the mapping or VARRAY to Java datatype...
    I just read something on oracle.sql.array ....that is the solution for mapping Oracle VARRAY to Java data type... but still I dont have a working code...
    Any help is highly appreciated...

  • Oracle.sql.BLOB as array

    Hi,
    I have a database table(say MY_BLOB_TABLE.) having one blob column
    I want to send each blob column as an attachment to a single email i.e. I for a particular case if I have 10 qualifying rows in MY_BLOB_TABLE,I want to send all these 10 blobs as different attachments with a SINGLE email.
    I have the working code (from asktom) that allows me to send one attchment per email ..so I changed the code so that it takes array types to the things..
    here is my code:
    Database Type:
    create or replace type xx_blobdata is varray(50) of blob;
    create or replace type xx_attachedfile is varray(50) of varchar2(1000);
    create or replace type xx_attachedfiletype is varray(50) of varchar2(1000);
    Java Code
    public class xx_attachments_mail
    static String dftMime = "application/octet-stream";
    static String dftName = "filename.dat";
    public static oracle.sql.NUMBER
    send(String from,
    String to,
    String cc,
    String bcc,
    String subject,
    String body,
    String SMTPHost,
    oracle.sql.BLOB[] attachmentData,
    String[] attachmentType,
    String[] attachmentFileName);
    PLSQL Wrapper
    create or replace function xx_attachments_mail_send(
    p_from in varchar2,
    p_to in varchar2,
    p_cc in varchar2,
    p_bcc in varchar2,
    p_subject in varchar2,
    p_body in varchar2,
    p_smtp_host in varchar2,
    p_attachment_data in xx_blobdata,
    p_attachment_type in xx_attachedfiletype,
    p_attachment_file_name in xx_attachedfile) return number
    as
    language java name 'xx_attachments_mail.send( java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    oracle.sql.BLOB[],
    java.lang.String[],
    java.lang.String[]
    ) return oracle.sql.NUMBER';
    Actual Call:
    attachment_data :=xx_blobdata();
    attachment_type :=xx_attachedfiletype();
    attachment_name :=xx_attachedfile();
    ret_code := xx_attachments_mail_send(
    p_from => '[email protected]',
    p_to => '[email protected]',
    p_cc => NULL,
    p_bcc => NULL,
    p_subject => 'testing',
    p_body => 'testing..',
    p_smtp_host => 'myserver.com',
    p_attachment_data => attachment_data,
    p_attachment_type => attachment_type,
    p_attachment_file_name => attachment_name);
    Everything compiles. All objects are valid in database.But when I call I get the following error:
    ORA-29531: no method send in class xx_attachments_mail
    ORA-06512: at "XX_ATTACHMENTS_MAIL_SEND", line 1
    Can anybody point out what is wrong that I am doing.
    Thanks.

    Duplicate post:
    Re: oracle.sql.BLOB array
    Devang,
    You asked:
    Can anybody point out what is wrong that I am doing?Yes, I can.
    VARRAY maps to "java.sql.Array" or "oracle.sql.ARRAY".
    You can find more details in the JDBC Developer's Guide and Reference which is part of the Oracle documentation, as well as the JDBC sample code which can be accessed from here:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    Good Luck,
    Avi.

  • Oracle.sql.BLOB and oracle.sql.STRUCT

    I'm development a application in Java with oracle, to manage media files. When I try to insert into oracle , I have this problem "oracle.sql.BLOB cannot be cast to oracle.sql.STRUCT" , and I don't know what that can be ..
    This is my code , please help with that.. If you have a smaple code of java and oracle to insert media , that will be a great help ..
    public void loadDataFromStream(OracleConnection con)
    try {
    Statement s = con.createStatement();
    OracleResultSet rs = (OracleResultSet)
    s.executeQuery("select * from blobs where id='video2.avi' for update ");
    String index = "";
    while(rs.next())
    index = rs.getString(1);
    index+="1";
    System.out.println("llego hasta aki");
    // el error esta en esta linea de abajo ...
    OrdVideo vidObj = (OrdVideo) rs.getCustomDatum(2, OrdVideo.getFactory());
    //rs.getBfile(3);///
    FileInputStream fStream = new FileInputStream("/home/jova/movie.avi");
    vidObj.loadDataFromInputStream(fStream);
    vidObj.getDataInFile("/home/jova/movie.avi");
    fStream.close();
    System.out.println(" getContentLength output : " +
    vidObj.getContentLength());
    OraclePreparedStatement stmt1 =
    (OraclePreparedStatement) con.prepareCall("update blob_col set image = ? where id = " + index);
    stmt1.setCustomDatum(1,vidObj);
    stmt1.execute();
    stmt1.close() ;
    index+="1";
    System.out.println("OK");
    catch(Exception e) {
    System.out.println("exception raised " + e);
    System.out.println("load data from stream unsuccessful");
    }

    I'm development a application in Java with oracle, to manage media files. When I try to insert into oracle , I have this problem "oracle.sql.BLOB cannot be cast to oracle.sql.STRUCT" , and I don't know what that can be ..
    This is my code , please help with that.. If you have a smaple code of java and oracle to insert media , that will be a great help ..
    public void loadDataFromStream(OracleConnection con)
    try {
    Statement s = con.createStatement();
    OracleResultSet rs = (OracleResultSet)
    s.executeQuery("select * from blobs where id='video2.avi' for update ");
    String index = "";
    while(rs.next())
    index = rs.getString(1);
    index+="1";
    System.out.println("llego hasta aki");
    // el error esta en esta linea de abajo ...
    OrdVideo vidObj = (OrdVideo) rs.getCustomDatum(2, OrdVideo.getFactory());
    //rs.getBfile(3);///
    FileInputStream fStream = new FileInputStream("/home/jova/movie.avi");
    vidObj.loadDataFromInputStream(fStream);
    vidObj.getDataInFile("/home/jova/movie.avi");
    fStream.close();
    System.out.println(" getContentLength output : " +
    vidObj.getContentLength());
    OraclePreparedStatement stmt1 =
    (OraclePreparedStatement) con.prepareCall("update blob_col set image = ? where id = " + index);
    stmt1.setCustomDatum(1,vidObj);
    stmt1.execute();
    stmt1.close() ;
    index+="1";
    System.out.println("OK");
    catch(Exception e) {
    System.out.println("exception raised " + e);
    System.out.println("load data from stream unsuccessful");
    }

  • Issue with java.lang.ClassCastException: oracle.sql.StructDescriptor

    Hi ,
    I'm creating a dbadapter for a custom API written in APPS schema -
    TYPE MISIPM_LOB IS RECORD (
    FILE_ID IPM_LOBS.FILE_ID%TYPE,
    FILE_NAME IPM_LOBS.LOB_NAME%TYPE );
    TYPE MISIPM_LOB_LIST IS TABLE OF MISIPM_LOB;
    PROCEDURE GET_FILE_ID_DETAILS(
    P_SOURCE_SYSTEM IN VARCHAR2,
    p_entity_value IN VARCHAR2,
    p_entity_code IN VARCHAR2,
    P_ORG_ID IN NUMBER,
    P_MISIPM_FILES_LIST OUT MISIPM_LOB_LIST,
    P_ERRCODE OUT VARCHAR2,
    P_ERRMESSAGE OUT VARCHAR2);
    From JDeveloper, there is a wrapper package is getting created and the compilation/deployment of this composite is also without any error.
    But when I run the composite, I'm surprisingly getting the below error -
    Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'GetAttachmentMetaData' failed due to: Interaction processing error. Error while processing the execution of the APPS.BPEL_GETATTACHMENTMETADATA1.XX_DELIVER_BLOB$GET_FILE_ API interaction. An error occurred while processing the interaction for invoking the APPS.BPEL_GETATTACHMENTMETADATA1.XX_DELIVER_BLOB$GET_FILE_ API. Cause: java.lang.ClassCastException: oracle.sql.StructDescriptor Check to ensure that the XML containing parameter data matches the parameter definitions in the XSD. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
    I recreated the adapter multiple times within the composite and also tried to create a separate composite and all the cases the error message received was same. There two more similar procedure call's in the composite and all rest of them are working fine.
    I can call the wrapper from sql script separately.
    Verified that the XSD generated and the wrapper package parameters are matching as well.
    Did anyone face the same issue or any explanation/help is much appreciated.
    Regards,
    Debanjan

    Hi Vijay,
    I have checked the number of parameters as well.
    <element name="InputParameters">
    <complexType>
    <sequence>
    <element name="P_SOURCE_SYSTEM" type="string" db:index="1" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_ENTITY_VALUE" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_ENTITY_CODE" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_ORG_ID" type="decimal" db:index="4" db:type="NUMBER" minOccurs="0" nillable="true"/>
    </sequence>
    </complexType>
    </element>
    <element name="OutputParameters">
    <complexType>
    <sequence>
    <element name="P_MISIPM_FILES_LIST" type="db:APPS.XX_DELIVER_X35784324X1X5" db:index="5" db:type="Array" minOccurs="0" nillable="true"/>
    <element name="P_ERRCODE" type="string" db:index="6" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_ERRMESSAGE" type="string" db:index="7" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    </sequence>
    </complexType>
    </element>
    <complexType name="APPS.XX_DELIVER_X35784324X1X6">
    <sequence>
    <element name="FILE_ID" type="decimal" db:type="NUMBER" minOccurs="0" nillable="true"/>
    <element name="FILE_NAME" db:type="VARCHAR2" minOccurs="0" nillable="true">
    <simpleType>
    <restriction base="string">
    <maxLength value="2000"/>
    </restriction>
    </simpleType>
    </element>
    </sequence>
    </complexType>
    <complexType name="APPS.XX_DELIVER_X35784324X1X5">
    <sequence>
    <element name="P_MISIPM_FILES_LIST_ITEM" type="db:APPS.XX_DELIVER_X35784324X1X6" db:type="Struct" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
    </sequence>
    </complexType>
    Regards,
    Debanjan

Maybe you are looking for

  • How can I print out a Panorama image to fill up the paper

    I have a HP Officejet Pro 8500A printer and have taken a picture in the Panorama setting and want to print it out on a 4x6 but have it fill up the complete 4x6 paper, not just the center part of the paper. Can this be done without losing quality and

  • Move tool crashes Photoshop CS4

    Hey =] I have quite a large problem with  PS CS4, Whenever I use the move tool, I get the message "Photoshop CS4 has encountered a problem and needs to close" I'm running Vista 32-Bit. It worked fine until about a week ago when I de-fragged my HDD, I

  • Is there any way to find out who accessed the BW reports in Portal

    Hi! Experts We have some BW reports which are published through SAP Portal and access given to only Team Leaders, now we want to see who are accessed or trying to access those reports other then Team leaders. Is there any way we can generate a LOG fi

  • Old ipod mini A1051 doesn't appear in itunes

    When I plug my old Ipod Mini into Mac it doesn't appear in Itunes, but it works otherwise and charges off the cable I'm using can anyone help?

  • Photoshop Elements 11 cannot find Qtcore4.dll

    Photoshop Elements 11 cannot find Qtcore4.dll. I have removed the program and re-installed twice and have run sfc/scannow. I still get the error on starting the program. A web search does not give any definite answers