You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by firstname lastname <su...@fastmail.fm> on 2005/09/16 02:33:39 UTC

need jdbc insert CLOB example

I need a simple but complete example of how to insert a CLOB into derby
via jdbc.
Any help would be appreciated.
-- 
  firstname lastname
  supermail99@fastmail.fm

-- 
http://www.fastmail.fm - Send your email first class


Re: need jdbc insert CLOB example

Posted by V Narayanan <V....@Sun.COM>.
Hi,
You could also take a look at the derby reference manual at this link

http://db.apache.org/derby/docs/10.1/ref/rrefclob.html

This page explains about the clob datatype and also contains an example 
of how to use it.

thanx,
V.Narayanan




Jean T. Anderson wrote:
> firstname lastname wrote:
> 
>> I need a simple but complete example of how to insert a CLOB into derby
>> via jdbc.
>> Any help would be appreciated.
> 
> 
> I keep thinking that there must be a complete example by now in the 
> derby mail archives, but I'm not putting my finger on one yet. In the 
> meantime, the functional tests might help:
> 
> http://svn.apache.org/repos/asf/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ 
> 
> 
> You might look at the code in blobclob4BLOB.java, LOBTest.java, and 
> blobSetBinaryStream.java .
> 
> I hope this helps. Feel free to ask for help if you don't find what 
> you're looking for.
> 
>  -jean
> 
> 



Re: need jdbc insert CLOB example

Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
firstname lastname wrote:
> I need a simple but complete example of how to insert a CLOB into derby
> via jdbc.
> Any help would be appreciated.

I keep thinking that there must be a complete example by now in the 
derby mail archives, but I'm not putting my finger on one yet. In the 
meantime, the functional tests might help:

http://svn.apache.org/repos/asf/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/

You might look at the code in blobclob4BLOB.java, LOBTest.java, and 
blobSetBinaryStream.java .

I hope this helps. Feel free to ask for help if you don't find what 
you're looking for.

  -jean


Re: need jdbc insert CLOB example

Posted by Lars Clausen <lc...@statsbiblioteket.dk>.
On fre, 2005-09-16 at 02:33, firstname lastname wrote:
> I need a simple but complete example of how to insert a CLOB into derby
> via jdbc.
> Any help would be appreciated.


    public static void setClobMaxLength(PreparedStatement s, int
fieldNum,
                                        String contents, long maxSize,
                                        Object o, String fieldName)
            throws SQLException {
        if (contents != null) {
            if (contents.length() > maxSize) {
                throw new PermissionDenied(fieldName + " of " + o
                        + " is longer than " + maxSize + " characters");
            }
            s.setCharacterStream(fieldNum, new StringReader(contents),
                    contents.length());
            s.setString(fieldNum, contents);
        } else {
            s.setNull(fieldNum, Types.CLOB);
        }
    }

Here's how you set the contents.  The rest is identical to inserting
other things.

-Lars