Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using Blob in Databases
This is the code that I'm using that's working: (for a Clob, for a Blob use
getBinaryOutputStream() instead of Character)
oConn = DriverManager.getConnection
("jdbc:oracle:thin:@myserver:1521:orcl", "user","password");
oConn.setAutoCommit(false);
cstmt = oConn.prepareCall("{call pk_clob.getClob(?,?)}");
cstmt.setInt(1,0); cstmt.registerOutParameter (2, OracleTypes.CURSOR); cstmt.execute (); try{ oRS = (OracleResultSet)(((OracleCallableStatement)cstmt).getCursor (2)); if (oRS.next()){ oClob = oRS.getCLOB(2); Writer bw=oClob.getCharacterOutputStream(); try { bw.write("This is some test text blah"); bw.close();
} catch (Exception ioe){
ioe.printStackTrace();
}
} } catch (Exception ioe){ ioe.printStackTrace();
}
cstmt.close(); oConn.commit();
where pk_clob is a package that contains:
procedure getClob(myid in int, myclob in out crshortclob)
is
begin
open myclob for
select id,clobdata from clobs
where id=myid
for update;
end;
where clobs is a table that contains an ID column (int) and the data (clob)
hope this helps
--
JP Moresmau
jpmor_at_gofree.indigo.ie
http://frenchstud.io
Received on Wed Feb 23 2000 - 12:49:42 CST
![]() |
![]() |