Re: Using jdbc to write data to Clob column

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Thu, 20 Jun 2002 23:12:40 -0700
Message-ID: <3D12C3D8.C92549A_at_rationalconcepts.com>


Hi John,
  well, I did my test case over a year ago against an 8.0.4 database writing probably jdk1.2 code, jdbc 1.0 api as supported by the oracle thin driver.   Oracle liked the blob/clob to be initialized first before using it.

  Now, take a look at the notes
http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/sql3.html

  for the new features in the JDBC 2.0 api. This will of course be dependent upon the driver supporting the 2.0 api, or not.   At http://technet.oracle.com/tech/java/sqlj_jdbc/content.html, the claim is that the drivers support the 2.0 api as well as some 3.0 api.

  So, give the tutorial section a whirl.

hth,
Cindy

"J. Harris" wrote:

> Cindy,
>
> Thanks, I've checked this out. My problem is that I'm trying to develop this
> without importing oracle.*, to make it as generic as possible. I guess some
> questions I need to have answered are:
>
> The code I'm trying to update will only have access to a PreparedStatement
> object, does this mean on an insert I would have to do an "insert into
> tableA (clob_field) values ('empty_clob()')", then acquire a ResultSet and
> rs.getClob()? So I can't use the setCharacterStream() of the
> PreparedStatement object when trying to insert a row?
>
> -John
>
> "C. Ferguson" <c_ferguson_at_rationalconcepts.com> wrote in message
> news:3D12B275.2F45ABE5_at_rationalconcepts.com...
> > Hi,
> > have a look at
> >
> http://technet.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/LOB
> Sample/LOBSample.java.html
> >
> > If you don't have a technet account, sign up for one. They are free.
> Then
> > browse the site.
> >
> > hth,
> > Cindy
> >
> > "J. Harris" wrote:
> >
> > > I'm trying to get the following code to work, however when I do run the
> code
> > > below I get an Io exception: Connect reset by peer: socket write
> error...
> > >
> > > if (column.isClob())
> > > {
> > > String str = column.getValue();
> > > int strlength = str.length();
> > > Reader reader = new StringReader(str);
> > > stmt.setCharacterStream(ps++, reader, rlength);
> > > }
> > >
> > > int ret = stmt.executeUpdate();
> > >
> > > Any ideas?
> >
Received on Fri Jun 21 2002 - 08:12:40 CEST

Original text of this message