Inserting in a BLOB using oracle BLOB

Inserting in a BLOB using oracle BLOB

Post by Gordon Twaddel » Sat, 12 Aug 2000 04:00:00



LOBs are handled differently than all the other data types.
Once you get a BLOB object reference it communicates directly
with Oracle, so you don't need the rs.updateRow() call.

    - Gordon

  I am trying to enter data (more than 50K) in a blob field
  This is my code
            con.setAutoCommit(false);
            ResultSet rs=st.executeQuery("SELECT BDATA FROM BINARY_DATA WHERE DC_IDENTIFIER=2 for update");
            rs.next();
            BLOB blob=(BLOB)rs.getObject(1);
            OutputStream os= blob.getBinaryOutputStream();

  // Byte[] bts
            os.write(bts,0,bts.length);
            os.flush();
            os.close();
            rs.updateRow();

  This is the error:
  java.sql.SQLException: Invalid operation for read only resultset: updateRow

  Any ideas on how to do this?

  I have already failed to use setBinaryStream with such a large buffer.

  Thank's in advance

  Be well!

  milko

 
 
 

Inserting in a BLOB using oracle BLOB

Post by Gordon Twaddel » Thu, 17 Aug 2000 04:00:00


I not positive on this, but i believe that this is a restriction on the table
that contains the BLOB.  So, you'll need to talk with your DBA to reconfigure
the table.  Oracle has the option to store the BLOB column in a separate table(s)
and that's how I'm configured.  My guess is that you're storing the BLOB column in
the same table as the rest of the columns. I've been able to store/retrieve 10 MB BLOBs
with no problems.

    - Gordon

  You were right!!!
  The problem is now that no matter how much data I
  try to insert only the first 1 or 2 Kbytes end up in the database

  I get no exception while inserting but when I try to
  read the file it turns out that it is too short

  My reading code is correct (has worked correctly
  with files > 3MBytes)

  Any more ideas??


    LOBs are handled differently than all the other data types.Once you get a BLOB object reference it communicates directlywith Oracle, so you don't need the rs.updateRow() call.     - Gordon

 
 
 

Inserting in a BLOB using oracle BLOB

Post by Manolis Wallac » Fri, 18 Aug 2000 16:06:25


Please repost your message
I get an error message from the news server and I cannot read it

Thank's

Manolis

Be Well !!

  mw.vcf
< 1K Download
 
 
 

Inserting in a BLOB using oracle BLOB

Post by Manolis Wallac » Fri, 18 Aug 2000 04:00:00


I think I am close so I am posting my findings
Anyone who can help me get this to the end is more than welcome:

Using Writer you can insert as long a file as you like in a LOB.
The problem is that Writer treats everything as ascii, so if you use it
to
insert binary data it might be corrupted by this process.

If you can think of a class that works like a binary Writer
I am pretty sure the problem will be solved.

For those who wonder what the problem is:
No matter which approach you use with thin driver
if your file is longer than a few KBytes you cannot succesfully
(and fully) insert it into a LOB (BLOB) field

Thank's for any ideas

Be Well!!

A thread already exists about this, but I don't
seem to be able to access it any  more]

  mw.vcf
< 1K Download
 
 
 

Inserting in a BLOB using oracle BLOB

Post by charles.john.. » Fri, 18 Aug 2000 04:00:00


Read up on ByteArrayInputStream and ByteArrayOutputStream classes. These
will do what you are wanting to do. I use them to move BLOBs into and out
of an informix database.

Cheers--
Charles



Quote:> I think I am close so I am posting my findings
> Anyone who can help me get this to the end is more than welcome:

> Using Writer you can insert as long a file as you like in a LOB.
> The problem is that Writer treats everything as ascii, so if you use it
> to
> insert binary data it might be corrupted by this process.

> If you can think of a class that works like a binary Writer
> I am pretty sure the problem will be solved.

 
 
 

Inserting in a BLOB using oracle BLOB

Post by Manolis Wallac » Fri, 18 Aug 2000 04:00:00


Charles thank's a lot
your pointer was exactly what I needed.

To the rest who might still be searching:
if this news thread does not contain everything you need feel free to mail me
for a working example.


> Read up on ByteArrayInputStream and ByteArrayOutputStream classes. These
> will do what you are wanting to do. I use them to move BLOBs into and out
> of an informix database.

> Cheers--
> Charles

  mw.vcf
< 1K Download