Problem Updating BLOB Data in DB

Hi, There,
I have a problem when updating BLOB data in database table. I am
using Oracle 8.1.6, JDK1.3.0., oracle thin driver.
I have a Handle object handle (javax.ejb.Handle), and I need to
save this object in DB. The table has 2 columns: column 1
is "PK" Varchar2(30) Primary Key, column 2 is "HANDLE" BLOB.
According to the documentation I found from Oracle, I first
initialize the blob column, and then get the BLOB locator.
However when I try to update the BLOB data by invoking
executeUpdate() method on OraclePreparedStatement ops, I always
get the returned int rowCount=0, which indicates that no rows
have been updated. (This is verified by trying to retrieve the
BLOB column value which results in SQLException: Exhausted
Resultset.)
Any suggestions what was wrong with the code? Thank you a lot in
advance!
Tom
Part of the code is listed below:
// If jSessionID is not found, create it
HttpSession session = request.getSession(true);
String jSessionID = session.getId();
//get the Hanlde object for MemberInfo bean
javax.ejb.Handle handle = memberValidate.validateMember(
memberID, "" );
oracle.sql.BLOB oracleBlob = null;
/* Get DB connection */
try
Connection conn = getDBConnection(); // with oracle thin driver
conn.setAutoCommit(false);
catch (NamingException ne)
System.out.println( "Failed to getDBConnection due to Naming
Exception" + ne.toString() );
return;
catch (SQLException sqle)
System.out.println( "Failed to getDBConnection due to SQL
Exception"+ sqle.toString() );
return;
try
pstmt=conn.prepareStatement("CREATE TABLE TOM1 (PK VARCHAR(30)
PRIMARY KEY, HANDLE BLOB NOT NULL)");
pstmt.execute();
pstmt=conn.prepareStatement("INSERT INTO TOM1 VALUES('ROW1',
EMPTY_BLOB())");
pstmt.executeUpdate();
pstmt=conn.prepareStatement("SELECT HANDLE FROM TOM1 WHERE
PK=? FOR UPDATE");
pstmt.setString(1, "ROW1");
ResultSet rset = pstmt.executeQuery();
if ( rset.next() )
// Get the LOB locator from the ResultSet
oracleBlob = ((OracleResultSet)rset).getBLOB("HANDLE");
OraclePreparedStatement ops = null;
ops = ( OraclePreparedStatement )
(conn.prepareStatement("UPDATE TOM1 SET HANDLE = ?
WHERE PK = ?"));
ops.setString( 2, jSessionID );
// using OutputStream to write object data
OutputStream oStream = oracleBlob.getBinaryOutputStream();
ObjectOutputStream outStream = new ObjectOutputStream
(oStream);
outStream.writeObject(handle); // handle is the Object to be
saved
outStream.close();
conn.commit();
conn.setAutoCommit(true);
ops.setBLOB( 1, oracleBlob );
int rowCount = ops.executeUpdate();
System.out.println("\n**** Rows affected: ");
System.out.println(ops.executeUpdate());
if (rowCount != 0)
// Commit the transaction:
System.out.println("\n**** conn.commit() OK...");
System.out.println("\n**** Handle saved in DB as Blob-type
OK...");
conn.commit();
conn.close();
else
System.out.println("\n**** ops.executeUpdate() == 0, Failed
to update DB");
conn.close();
return;
catch ( SQLException se )
se.printStackTrace();
return;
catch ( Exception e )
System.out.println(e.toString());
return;
System.out.println("\n**** DB update OK...");
null

You cannot update Blob column in Adf testing tool as far i think
check this blog might help you to store images in ADF http://baigsorcl.blogspot.com/2010/09/store-images-in-blob-in-oracle-adf.html

Similar Messages

  • Problem updating master data

    Hi all, im having a problem updating master data for an infoobject.
    Im not able to upload the data from the data source and im not able either to update it manually.
    Im getting this error Field symbol has not yet been assigned
    can anybody hekp me?

    Ask your Basis team to implement this note in BI system..
    Summary
    Symptom
    GETWA_NOT_ASSIGNED (a field symbol is not yet assigned) occurs when new master data providers are implemented after Note 1089231.
    Reason and Prerequisites
    This problem is caused by a program error.
    This problem only occurs when display attributes are requested and no data is returned.

  • Help! Problem Updating Blob Columns

    Good day
    Please i have problems updating Blob columns storing images and doc files. can someone put me through the way out hassle free
    Thank You
    God Bless U all
    Femi

    I keep geting this error
    java.sql.SQLException: ORA-01729: database link name expected
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
    when ever i try to update The Blob colum with a Blob object retrieved by resultset.getBlob from another Blob column of a different table.
    Blob b = rset.getBlob(1);
    String x = (String)jComboBox2.getSelectedItem();     
         ps=c.prepareStatement("UPDATE PROPERTIES SET "+x+" = "+b+" WHERE NAME = ?");
         ps.setString(1, (String)jComboBox1.getSelectedItem());
         System.out.println("success");
         ps.executeUpdate();

  • Problem update a date field

    Hi,
    I have one table with a date field.
    For display all rows in a table component i'm using a dateTimeConverter object with format 'dd/MM/aaaa' and work fine.
    Bat when i update a data provider with follow code:
    public String update_action() {
    // TODO: Process the button click action. Return value is a navigation
    // case name where null will return to the same page.
    try {
    myDataProvider.commitChanges();
    myDataProvider.refresh();
    } catch(Exception e) {
    error("One error: " + e.getMessage());
    return null;
    return from brawser the follow message:
    Number of conflicts while synchronizing: 1 SyncResolver.UPDATE_ROW_CONFLICT row 2 Data Exception -- No Applicable Cast Operator. from SQL type BINARY to SQL type DATE
    Anyone help me!
    Thanks.

    If you are getting the date from a calendar you have to convert it before storing it, for example, in the following code, the date got from the calendar is converted to a java.sql.Date
    java.sql.Date date1 = new java.sql.Date(calendar1.getSelectedDate().getTime());
    I hope this helps =)

  • Problem updating a date field via UnitOfWork - TopLink 9.0.3

    Hello,
    we want to change an exisiting application that employs TopLink 9.0.3, Build 423.
    The data is stored in an Oracle 9.2.0.6.
    The specific table has a composite primary key consisting of four fields.
    I can easily create a new Object (foo)
    uow.registerNewObject(foo)
    uow.commit()
    and see the results in the database.
    If I obtain an exising Object (bar) and change an integer
    bar = (Bar) Session.readObject(Bar.class, expr);
    cloneBar = (Bar) uow.registerObject(bar);
    cloneBar.setSomething(42);
    uow.commit()
    everything is fine.
    But if I dare to change a Date field
    cloneBar.setSomethingElse(cal.getTime());
    then
    uow.hasChanges()
    returns true
    but the update does not happen. It is neither logged nor is the data changed in the database.
    Is this a known bug?
    What have I done wrong?
    How can I avoid using hard-coded SQL to update my Bar object?
    Bye,
    Stephan

    Hello,
    it is very disturbing, but I finally found the reason for this problem.
    After decompiling the Project class file (we have no source code of this third-party library), I saw that the mapping for this specific field is set to "readOnly".
    I did not know that TopLink is able to have specific fields "readOnly" and others "readWrite", but it can handle this!
    So it seems that the behaviour is not a bug but a feature :-(
    We can change the mapping before creating the session, with the result that the field is updatable.
    Have a nice day.

  • Problem Updating Meta Data

    Hallo,
    I changed a SAP custom table (added 1 extra field). Next I tried to update the meta data in Visual Studio, but the new field of the table is missing.
    If I generate the proxy completely new, all fields of the table are visible.
    Is there any limitation for updating table meta data ? The table contains 80 fields befor changing and 81 fields after chainging.
    Any hints ?
    Best regards,
    G.Rausch
    P.S.: As "workaround" I deleted the old proxy and genareted a new one, which worked fine. But this is no satisfactory solution at all.

    Hello,
    I had the same problem in another VS Solution as well, but I managed to solve the problem
    After closing the sapwsdl[Design] and opening it again all fields are visible.
    Regards,
    Gerhard Rausch

  • Problems writing BLOB data into O8i (ADO and AppendChunk)

    We have a table where you want to store bianry data (BLOBs). I
    have used the LONG RAW datatype to store this information. Here
    is the code for the table:
    CREATE TABLE "CONTENTBLOBTABLE" (
    DIGEST NVARCHAR2(40) NOT NULL,
    BLOB LONG RAW,
    CHECK (DIGEST IS NOT NULL),
    PRIMARY KEY (DIGEST)
    Then we try to update this table with ADO 2.6 on a Windows 200
    machine with Oracle ODBC driver. Here is the relevant code
    snippet:
    // set the value of the field
    pRs->AddNew();
    pRs->Fields->GetItem("DIGEST")->PutValue(strDigest);
    pRs->Fields->GetItem("BLOB")->AppendChunk(varBLOB);
    if(!pRs->Update())
    C_LOG_CRITICAL(L"CC_CS_DAL::WriteBLOB - pRs->Update failed");
    *error = C_CS_CBT_ERROR;
    pRs->CancelUpdate();
    pRs->Close();
    m_pConn->Close();
    m_spObjectContext->SetAbort();
    return S_FALSE;
    OK, NO error occurs: no exception, HRESULT return values are all
    OK, method completes.
    BUT: there is no data in the table!?!?! When querying the exact
    same table we get an empty result!
    Any ideas please?
    Thanks,
    Christian

    Did you even get a reply to this message?

  • Problem updating basic data text for a certain language via MM01 / MM02

    We are facing the following problem :
    We have materials where we maintain the basic data text via MM02 in different languages ( Dutch, English, French, German, Japanese and polish).
    When we copy a material to a new one and we would like to update the basic data text we can do this directly except for some reason for Japanese.
    For japanese we first must press the Editor Icon, we than get the editor were we can change the text and from that moment on everyting is ok.
    But we would like to update the text like we do for the other languages without first pressing the editor icon.
    We are running 4.7 and the sapgui is 7.1 patch 18.

    We are facing the following problem :
    We have materials where we maintain the basic data text via MM02 in different languages ( Dutch, English, French, German, Japanese and polish).
    When we copy a material to a new one and we would like to update the basic data text we can do this directly except for some reason for Japanese.
    For japanese we first must press the Editor Icon, we than get the editor were we can change the text and from that moment on everyting is ok.
    But we would like to update the text like we do for the other languages without first pressing the editor icon.
    We are running 4.7 and the sapgui is 7.1 patch 18.

  • Problem with BLOB data type and acute characters

    Hi all, I have an issue related with BLOBS cols:
    I have table A with a BLOB column and I need to insert that data into another table B, the thing is I use dbms_lob.read() that returns data into a RAW variable and then I convert it to a varchar2(with utl_raw.cast_to_varchar2) and it works ok if I have no "acute characters" on it, e.g Québec.
    If I have acute characters, the "é" is inserted wrongly with an "¿" character on the table B. I tested the BLOB on the table A to check the data and the BLOB is showing correctly the "é" character, it seems that the dbms_lob.read() funct cannot handle accute characters and replace them with "¿".
    How can I replace acute characters when I use the dbms_lob.read functionality?
    Thank you!

    what's the OS of the db server? is this code an anonymous pl/sql block, or stored pl/sql? does it run on the server or a client? if it's on the client, what's the o/s of the client?
    you might want to look at the following, plus the first 3 notes in it's reference section
    https://metalink.oracle.com/metalink/plsql/f?p=130:14:3038746456038321058::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,264157.1,1,1,1,helvetica

  • Problem updating delivery date onto quotation

    Hi All-
    We have process, After creating sales order, will convert that into purchase req and again convert purchase req into STO's..
    Problem here is, if we make change delivery date onto STO's, should be reflect onto Purchase Req and also onto sales order...
    Anyone if you know the solution, please reply to my question and also let me know if there any user-exits to the sameissue...
    Thanks,
    Sony

    Hi,
    Pass the following values...
    POACCOUNT LIKE BAPIMEPOACCOUNT...
    poaccount-TAX_CODE = ? (value)....
    That should take care of the missing field.
    Regards,
    Madan..

  • Update blob data

    i wanna do the same as you ,and i can't save image whose size is more than 4kb ,too.but there is other difference,i find that the process corresponding to the request on the oracle server quit abnormal,i can see that in a file alert_sid.log and it refer to another file in which i found more information even assemble code.i think only the oracle technician can understand this information.why this happen?
    null

    Thank you for your reply.
    Oracle Database 10g Release 10.2.0.3.0
    I just can't confirm it is a Oracle problem or PowerBuilder problem.
    Actually, the database was migrated from Oracle 8i. I didn't have the problem in 8i, I recreated the table(SEAL_IMAGE) after upgrading using the same SQL code because the upgraded database didn't have the table. Then the problem appeared. What made me curious was the other tables (upgraded from 8i) which had blob columns worked well, so I thought it was because the table was created in 10g. I created the table (SEAL_IMAGE) in 8i and then upgrade the whole database to 10g. Alas! the problem persists. But when I created a completely new testing table, it worked.
    What do you mean 'BLOB column in-line'?

  • Problem storing BLOB data

    Hello all
    I have created a directory where I have some images and I'm trying to store these in my database using the code below. The code, schema for the image table and the error is shown below.
    SQL> DECLARE
    2 photo_loc BFILE;
    3 photo BLOB;
    4 BEGIN
    5 INSERT INTO image_ids VALUES(1,'P44240', EMPTY_BLOB(), 'an_image')
    6 returning image into photo;
    7
    8 photo_loc := BFILENAME('IMAGE_DATA', '18.jpg');
    9 DBMS_LOB.FILEOPEN(photo_loc);
    10
    11 DBMS_LOB.LOADBLOBFROMFILE(photo, photo_loc, DBMS_LOB.getlength(photo_loc), 1,1);
    12 DBMS_LOB.FILECLOSE(photo_loc);
    13 END;
    14 /
    DBMS_LOB.LOADBLOBFROMFILE(photo, photo_loc, DBMS_LOB.getlength(photo_loc), 1,1);
    ERROR at line 11:
    ORA-06550: line 11, column 77:
    PLS-00363: expression '1' cannot be used as an assignment target
    ORA-06550: line 11, column 79:
    PLS-00363: expression '1' cannot be used as an assignment target
    ORA-06550: line 11, column 2:
    PL/SQL: Statement ignored
    IMAGE_ID NOT NULL NUMBER(10)
    SI_PRODUCT_ID NOT NULL VARCHAR2(10)
    IMAGE BLOB
    IMAGE_DESCRIPTION VARCHAR2(100)
    Any help would be greatly appreciated.
    Thanks
    Ben.

    the error says that you have to replace the constant 1 with a variable. Please review the syntax.

  • Problem with BLOB Data Type

    Dear all
    I am using APEX 4.0, to show an image in my report I have this sql statement (built by using wizard) :
    SELECT ProductID, Pro_Name, Pro_Description, Pro_Quantity, Pro_SerialNo, Pro_ModelName, Pro_ModelNo, Pro_Retail, dbms_lob.getlength(Pro_Image)
    FROM Products
    but for the Image column in the report it only shows the numbers!
    any help?
    thanks
    Maz

    Check the Format-Mask of your image report column. To display images there should be a small link next to the format mask input item, where you can specify where to read the image from.
    See this documentation for some explanation: http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm
    brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    Work: http://www.click-click.at
    Training: http://www.click-click.at/apex-4-0-workshops

  • Updating array data in sql database

    HI,
    Im facing problems in updating array data in SQL database.
    As of now, i am able to write an "insert" query and insert array data in an image datatype field. Im using image datatype because the array size is very big(around 80,000 x and y values).
    Althoug inserting data is easy im unable to write a query to update this data.
    Referring to the help of SQL server and Labview database connectivity toolkit, i came across a method of accessing image datatype....using textpointers, which are 16 bit binary values and using the WRITETEXT function instead of the UPDATE function.
    but the problem im facing is that ive to pass the array as a 2d string array in the query as a result the updated array is retrieved in the form of a string a
    nd not as an array. how do I get over this problem?

    Hi Pavitra,
    I'm not very clear on how you have inserted the data into your application, but I do know that when you call the UPDATETEXT or WRITETEXT function you use the TEXTPOINTERS to point to the first location of a 1d array. So, depending on how you've stored the data, you may have problems updating your data if you're looking at it as a 1d array instead of how you originally formatted it. If you are able to successfully access the data as a 1d array, you can use the database variant to data type vi and pass in a string array constant for the data type. This will convert the variant datatype into whatever you specify. You may have to index the row and column of the variant (you receive a 2d array of variant) first before you convert. If possible, can yo
    u provide some more detail and maybe some example code of how you perform the insert and plan to do the update? I can probably give you a better solution if I know how you are formatting the data. Thanks!
    Jeremy L.
    National Instruments
    Jeremy L.
    National Instruments

  • Updating blob files

    can somebody help me, can mysql update blob data fields? or is there another way to change data i blob columns/...

    Hi,
    I've done this before in Oracle so not sure about mysql.
    In Oracle, we have to insert a row into the database with an empty BLOB using the empty_blob() function within Oracle.
    Then its a matter of calling a select on the row for UPDATE and streaming the BLOB into the database.
    eg.
    String sql = "INSERT into TABLE values (a,empty_blob());
    ... execute sql
    then select on the table like this
    String sql = "Select BLOB from TABLE where id = a for UPDATE; (Where BLOB is your Blob column name)
    execute sql and the BLOB value returned can be used
    BLOB blob = (BLOB)rs.getBlob(1);
    I had to cast from the java.sql.Blob type to the oracle.sql.BLOB type then get an output stream and stream your data in. I used a byte[] to do this.
    I'm not sure how you would go about this in mysql but maybe I've pointed you in the right direction.
    hope this helps

Maybe you are looking for