Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Reading CLOBs with JDBC
Hi Benjamin
> I've been trying to do CRUD (Create, Read, Update, Delete) functions
> with JDBC on table with a CLOB field. I've been able to successfully
> create rows, update and delete them, but when I try to populate a
No, you proberly haven't. I did it the same way as you do. By using bytes, but this is not the way. Not at all. (You can do a check and select the clob-field in a SQL-Plus. You should be able to read the field in clear-text, which you proberly are not. I wasn't)
You should do it in some way like this:
ResultSet CLOBresl = jdbc.query("SELECT clob_field "+ "FROM clobtable "+ "WHERE id = 1"); CLOBresl.next(); java.io.OutputStream out; oracle.sql.CLOB cl =
out =
(oracle.jdbc.driver.OracleClobOutputStream)cl.getAsciiOutputStream();
out.write(rating_model.pre_rate_script); out.flush(); out.close();
This is both for UPDATE and INSERT, please notice the select, also when updating! (Ugly way to do it, I think)
So when you insert you do this:
"Insert to clobtable values (' ')"
And then you select the field, like in the code above..
Frederik Hansen Received on Fri Sep 24 1999 - 02:10:54 CDT
![]() |
![]() |