Java.sql.Blob method setBinaryStream?

Hi,
I've been trying to use the java.sql.Blob methods instead of the "Oracle Extensions" so that people w/o Oracle (using MySQL etc.) can still use my code.
Problem: trying to get the OutputStream to write to the Blob. As of JDK1.4, java.sql.Blob has a method to do this, setBinaryStream. Unfortunately, calling this in Oracle JDBC (tried it in both thin and OCI version) throws an SQLException (Unsupported feature).
Sample code:
//Assume we already have a connection to the database, over either OCI or thin.
//Assume a Statement stmt created from the connection.
//Assume a table BlobTable with 2 fields : id (number) and data (blob).
public void uploadBlob(byte [] theBytes){
     try{
     stmt.executeUpdate("INSERT INTO BlobTable (id, data) VALUES (1,empty_blob())");
     ResultSet rs = stmt.executeQuery("SELECT data FROM BlobTable WHERE id=1 FOR UPDATE");
     if (rs.next()){
java.sql.Blob blob=rs.getBlob(1);
     OutputStream out=blob.setBinaryStream(0);
     //Next line never printed - error thrown.
     System.out.println("Got Stream");
     catch(Exception e){e.printStackTrace();}
//End code
Am I doing something wrong? Or is there simply no way to write to a Blob without using the extensions?
None of the docs (examples, guides, etc) make any mention of this, although the JDBC dev guide does mention that the similar method in PreparedStmt only works over OCI.
Thanks,
Dan

Hi lancea,
It's been a while since this thread was active, but I have a related question.
Is there a comprehensive list of changes between JDBC 3 and JDBC 4 that makes application not work any more, such as this setBinaryStream issue or the CallableStatement/Named parameters issue that we stumbled upon. We would like to address these issues proactively and not find out about them in production, since we're upgrading from jdk1.4 to jdk6. Oracle has provided us with their changes regarding database versions, but have been less forthcoming with JDBC spec version changes.
Thanks in advance,
Thomas Auzinger

Similar Messages

  • Creating/constructing a java.sql.Blob and writing to Oracle with jdbc

    I'm trying to understand how to create a blob from an image file to write it to a Oracle database using jdbc.
    I know there'a a getBinaryStream method in java.sql.Blob to which I can write the files byte array, but how do I create an actual blob in the first place. All examples I've seen initialise the blob from an exiting Blob field in a database which I do not have filled yet
    thanks

    In general, you will do something like the following:
    Ensure setAutoCommit is false
    INSERT INTO foo (blob_column) values (empty_blob());
    SELECT blob_column FROM foo FOR UPDATE;
    Call getBlob() on the ResultSet
    Cast it to Oracle's specific BLOB (different object)
    Call getBinaryOutputStream() on the BLOB
    Pipe your data
    Commit (very importatnt as FOR UPDATE will lock that row)- Saish

  • Datasource, POJO and java.sql.Blob

    Hello,
    is "java.sql.Blob" a valid type for a POJO datasource ?
    I declared one but I just dit not succeed in rendering its jpg picture.
    My java code is quite simple :
    ReportClientDocument reportClientDocument = new ReportClientDocument ();
    reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);
    reportClientDocument.open (REPORT_NAME, OpenReportOptions._openAsReadOnly);
    // lBlob is a class which implements java.sql.Blob interface
    LPOJOData [] dataP = {new LPOJOData(new lBlob("Picture.jpg"))};
    POJOResultSetFactory factory = new POJOResultSetFactory(LPOJOData.class);
    POJOResultSet resultSet = factory.createResultSet(dataP);
    reportClientDocument.getDatabaseController().setDataSource(resultSet, "", "");
    and my POJO class :
    public class LPOJOData {          
              private java.sql.Blob zimage;
              public LPOJOData(java.sql.Blob zp){
                   this.zimage = zp;
              public java.sql.Blob getzimage(){
                   return zimage;
    The field "zimage" on the report is designed through a "field definition only" database, zimage is defined as a Blob field.
    Any clues ?
    Regards,
    Serge

    I have just found a list of the data types supported by a POJO Class :
    # boolean
    # byte
    # char
    # double
    # float
    # int
    # short
    # java.lang.Boolean
    # java.lang.Byte
    # java.lang.Double
    # java.lang.Float
    # java.lang.Integer
    # java.lang.Short
    # java.lang.String
    # java.SQL.Date
    # java.SQL.Time
    Well, java.SQL.Blob is not one of them.
    Is java.SQL_Blob will be a valid POJO type in the future ?
    Is there another way than POJO to feed a report from an in-memory datasource ?

  • Store a uploaded file of type binary into a java.sql.Blob

    Hi all,
    I try a File-Upload and store the file in a  java.sql.Blob of a MaxDB.
    My Problem is, that I'm not able to import a Model-Attribute of data type byte[]. Further I don't no how to convert the uploaded value attribute of data type binary, in a java.sql.Blob.
    Regards,
    Silvia Hofmann

    http://www.excelsior-usa.com/jet.html
    http://www.ej-technologies.com/products/exe4j/overview.html
    http://jsmooth.sourceforge.net/
    Distributing your Application as an executable JAR file
    Google is your friend.

  • Get canvas.toDataURL('image/jpeg') and convert base64 encoding to java.sql.Blob

    Convert canvas.toDataURL('image/jpeg') to java.sql.Blob.
    I am using oracle adf so I am able to action a backing bean from javascript and pass in parameters as a map. I pass in the canvas.toDataURL('image/jpeg') which I then try to decode in my bean. Using BASE64Decoder and the converting the bytearray to a file I can see the image is corrupted as I can't open the file thus converting the bytearray to blob is also a waste.
    Has anyone any ideas on base64 encoding from canvas.toDataURL to file or Blob?

    Use Case:
    A jsf page that enables a user to take photos using the HTML5 canvas feature - interact with webcam -, take photos and upload to profile
    1. I have created the jsf page with the javascript below; this pops up as a dialog and works okay and onclick an upload image, triggers the snapImage javascript function below and sends the imgURL parameter to the serverside managedbean
    <!-- java script-->
    function snapImage(event){
                    var canvas = AdfPage.PAGE.findComponent('canvas');
                    AdfCustomEvent.queue(event.getSource(),"getCamImage",{imgURL:canvas.toDataURL('image/jpeg'),true);
                    event.cancel();
    <!-- bean -->
    public void getCamImage(ClientEvent ce){
    String url=(String)ce.getAttributes().get("imgURL");
    decodeBase64URLToBlob(url);
    private BlobDomain decodeBaseB4URLToBlob(String url64){
                    BASE64Decoder de=new BASE64Decoder();
                    byte[] bytes=de.decode(url64);
                    File file=new File("abc.jpg");
                    InputStream in = new ByteArrayInputStream(bytes);
                    BufferedImage bImageFromConvert = ImageIO.read(in);
                    in.close();
                    ImageIO.write(bImageFromConvert, "jpg", file);
                    return createBlobDomainFromFile(file);
    ----problem---
    Accessing the generated jpeg file shows the image is corrupted, probably missing bytes or encode/decoder issues.and the blob image after uploading to database is saved as a binary stream which ondownload doesnt render as an image or anything i know of.
    Is there anyways of achieving the conversion without errors?

  • Make java.sql.Blob object from java serialized object

    I have an ImageIcon which I get from an applet. It gets passed to a servlet. Now, I want to turn the ImageIcon into a blob object so that I can insert it into a database (as/400). How do I do that?

    Hi there,
    NORMALLY this is a 2-step process:
    1.) Convert the ImageIcon into a byte-array
    2.) Write the byte-array into the database/blob
    For step 1 (this code is 'freehand'):
    =====================================
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.write(myImageIcon);
    oos.close();
    byte[] data = bos.getBytes();
    For step 2:
    ============
    This is often database specific, but normally you select a column of a record for update, get the blob-object from the resultset and start writing bytes to it.
    BUTTTTTTTT Consider this alternate approach: Assuming the image that is being sent is always small in size, you may simply chose to base-64 encode it and store the resultant string in a varchar column. When you read it back, base-64 decode it. Although the encoding/decoding may appear to be an overhead, I'll bet you it's much faster than blob-level access, both for reads and writes. It's also portable (code-wise) and you can update images through a simple UPDATE statement. In fact, if your database supports it, you could even have a default value for the column (a default image)...

  • 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;
    }

  • 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);

  • Can I use ' ', ' ', '= ' and ' =' with java.sql.Timestamp objects in EJB-QL

    ie. Is this valid?
    <query>
    <description>Find data between dates</description>
    <query-method>
    <method-name>findMetricsByDate</method-name>
    <method-params>
    <method-param>java.sql.Timestamp</method-param>
    </method-params>
    <method-params>
    <method-param>java.sql.Timestamp</method-param>
    </method-params>
    </query-method>
    <result-type-mapping>Local</result-type-mapping>
    <ejb-ql>
    SELECT OBJECT (o) FROM MetricResults AS o WHERE MetricResults.date > ?1 AND MetricResults.date < ?2
    </ejb-ql>
    </query>

    No. Not with current EJB 2.0 CMP specs at least. Later revisions are supposed to fix this, but for now, this seriously limits the usefulness of EJB-QL.
    .P.

  • How to get java.sql.Timestamp data from database

    Hello, i'm new to EJB and i can't get java.sql.Timestamp data, but when i'm trying to get java.lang.String data it works fine.
    * @ejb.finder
    * query="SELECT OBJECT(c) FROM userSCHEMA AS c
    *      WHERE c.lastName LIKE ?1
    * AND c.firstName LIKE ?2
    * AND c.registeredDate < ?3"
    * signature="java.util.Collection findPatient * (java.lang.String lastName,
    * java.lang.String firstName,
    * java.sql.Timestamp)"
    <method-params>
    <method-param>java.lang.String</method-param>
    <method-param>java.lang.String</method-param>
    <method-param>java.sql.Timestamp</method-param>
    </method-params>
    Where i made a mistake ?

    The main problem that I'm faced with, is that the
    java.sql.Timestamp now has only one constructor, it
    takes "long", i.e., milliseconds.That's because a Timestamp is just an offset from a particular instant of time. It doesn't have a timezone.
    Please note that I'm not trying to "print", i.e., I'm
    not interested in using the SimpleDateFormat.Then what are you interested in? You appear to be trying to create a Timestamp with a particular timezone, which doesn't make sense as I already noted. Is there a reason for this?

  • Java.lang.AbstractMethodError: oracle.sql.BLOB.setBytes

    Hi ,
    When I deployed an application ( In Oracle 10g )that uses oracleresultset i am getting an error as follows java.lang.AbstractMethodError: oracle.sql.BLOB.setBytes
    anybody has a clue ?
    Vishnu

    Hi Vishnu,
    I got the same error, and also when trying blob.setBinaryStream(1L);
    By me the DB is an 8.1.6 and the JDBC Driver I tried are both the new 10.1 and older ones.
    Did you solve your problem ? In which case I would be interested in a solution. A work around seems to be the blob.getBinaryOutputStream() method, but this is a problem for me since it is not portable.
    Regards
    Michele

  • Sql.Blob:   java.sql.SQLException: Funzione non supportata   .....help me

    Hello,
    I hope you can help me :-) !!!!!!
    I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
    resultSet rs = ****query****
    ((oracle.jdbc.oracleSet) rs ).getBLOB(1);
    but throws ClassCastException on the cast oracleSet......
    i try withthis code:
    ResultSet rs = ****query****
    Blob b = rs.getBlob(1);
    OutputStream out = b.setBinaryStream(1);
    but throws java.sql.SQLException: Funzione non supportata
    Why?????
    what's can i do?
    help me!!!!!!!
    thanks

    Hello,
    I hope you can help me :-) !!!!!!
    I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
    resultSet rs = ****query****
    ((oracle.jdbc.oracleSet) rs ).getBLOB(1);
    but throws ClassCastException on the cast oracleSet......
    i try withthis code:
    ResultSet rs = ****query****
    Blob b = rs.getBlob(1);
    OutputStream out = b.setBinaryStream(1);
    but throws java.sql.SQLException: Funzione non supportata
    Why?????
    what's can i do?
    help me!!!!!!!
    thanks

  • 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

  • Using oracle.sql.BLOB data type in Java Class to pass in a Blob

    All,
    I'm trying to pass in a BLOB from PL/SQL to a Java Class, but the BLOB isn't passed correctly.
    When I check the length of the BLOB in PL/SQL its different from the length of the BLOB in java.
    I'm using DB 11g and the ojdbc5.jar file in my java classes.
    The java function uses the oracle.sql.BLOB type to get the parameter.
    The java class is loaded into the DB and called via a PL/SQL function.
    Kind regards,
    Nathalie

    The question is indeed a little ambigious defined ;o)
    When I pass the BLOB to the java method and invoke BLOB.getBytes() and then get the length of the BLOB in java the length of the BLOB is bigger than in PL/SQL.
    When I use the method 'getBinaryStream' and write this to a buffer, the code works.
    I will log a tar regarding the getBytes()-method to ask for more detailed information regarding the methods provided using the JDBC Drivers.
    Kind regards,
    Nathalie

  • Oracle.sql.BLOB.setBinaryStream() throws UnsupportedFeatureException

    Does anyone know why oracle.sql.BLOB.setBinaryStream(long pos) throws an UnsupportedFeatureException? It seesm to me that if the method were rewritten as:
    public OutputStream setBinaryStream(long pos) throws SQLException {
         return getDBAccess().newOutputStream(this, getBufferSize(), pos);
    ... then there would be no reason to throw an exception.
    Ideas?
    - David

    Hi Dave,
    I ran into this when I did rs.getBlob(1).setBinaryStream(0) using the ojdbc1_4 driver (without casting to oracle.sql.BLOB). Someone pointed out that I needed to select the BLOB column FOR UPDATE. I did this and now I am getting ORA-01002: fetch out of sequence.
    Not sure if I have helped you any...still digging around for the meaning of ORA-01002
    Raj

Maybe you are looking for