Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Reading CLOBs with JDBC

Re: Reading CLOBs with JDBC

From: <svenerik_at_mad.scientist.com>
Date: Fri, 15 Oct 1999 03:14:07 GMT
Message-ID: <7u665n$np2$1@nnrp1.deja.com>


In article <37EB23FE.AF391CD3_at_post1.tele.dk>,   Frederik Hansen <roirex_at_post1.tele.dk> wrote:
> 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 =
> ((oracle.jdbc.driver.OracleResultSet)CLOBresl).getCLOB(1);
>
> 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
>

Is there anyway anyone who has gotten this working could post a functional example of jdbc and blobs or clobs. What exactly is jdbc.query as shown above? Did you mean Statement.executeQuery??
Help, anybody. I'm considering just trying to install 8i which I guess is what oracle meant by upgrade the old oracle?? but if I can get this working under 8.0.5 that would be ideal. Sven

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Oct 14 1999 - 22:14:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US