Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why setClob() and setBlob()?
I'm not sure about the methods that you mention but I do know how you can write Blob/CLob data to Oracle via JDBC. Currently the method I have been using successfully is the following.
//Store the Blob/Clob data in a byte array,
byte [] barray = (bytes from external source, files, stream etc)
//create the necessary sql insert /update in a String varaible i.e.
String x = "insert into tableA values (val1, val2, ?)";
//Create an OraclePreparedStatement
OraclePreparedStatement opst = (OraclePrepareStatement)
conn.PrepareStatement(x);
opst.setBytes(1,barray);
int x = opst.executeUpdate();
opst.close();
If autocommit is false then you must call conn.commit();
I hope this helps / answers your questions / helps resolve your problem.
RHC
Julien Reynier wrote:
>
> Hi,
>
> After reading "Working with BLOBs and CLOBs" in "Oracle8i JDBC
> Developer's Guide and Reference Release 2 (8.1.6)"
> <http://oradoc.photo.net/ora816/java.816/a81354/oralob2.htm#1043220> I
> understand that you can't create or populate a BLOB or CLOB column and
> that you have to use them with a locator.
>
> So I see the use of getBlob() and getClob() methode to get CLOB or BLOB
> locator but I don't see setBlob() and setClob() use due to the fact that
> you update a CLOB or BLOB data by getting its locator and by writing
> data in as in this Oracle example:
> ...
> writer = ((CLOB)my_clob).getCharacterOutputStream();
> writer.write(data);
> writer.flush();
> writer.close();
> ...
> No setXXX() methode is necessary!!!
>
> Maybe I missunderstood the use of setClob() and setBlob()... Is there
> anybody to help me?
>
> Julien Reynier
-- Posted via CNET Help.com http://www.help.com/Received on Fri Mar 02 2001 - 12:30:09 CST
![]() |
![]() |