users@glassfish.java.net

Re: CLOB for LONG String values and OracleConnection from a DataSource

From: Hadraba Petr <hadrabap_at_gmail.com>
Date: Tue, 1 Jul 2008 23:25:58 +0200

And finally,

that's me again.

I see, you are writing XML into the database. I'm lucky user of
Oracle's XMLTYPE.

I have two stored procedures

1) CREATE PROCEDURE write_xml( aXml IN XMLTYPE )…

2) CREATE PROCEDURE get_xml( aXml OUT CLOB )…

The first procedure simply inserts aXml as is. The second one retrievs
the XML from the table using column_storing_xml.getClobVal().

The java calls look like:

1) { call write_xml( XMLTYPE( ? ) ) }

2) { call get_xml( ? ) }

I'm able to use XPath in the database and finally—pass the XML in the
java.lang.String form to the database backend. All is working on 10gR2
and 11gR1 with Java EE 5.

I'm writing this solution to you because of I spent several hours to
find them :-'(

Good luck!

PETR


On Tue, Jul 1, 2008 at 23:09, Hadraba Petr <hadrabap_at_gmail.com> wrote:
> Hi,
>
> that's amazing. My code is the following:
>
> Clob tClob = createClob(conn);
> tClob.truncate(0);
> tClob.setString(1, (String) arg.getValue());
>
> cStmt.setClob(i, tClob);
>
> My code comes from simple "framework" that simplyfies calling of
> stored procedures. It looks like the position within the Clob begins
> at position 1 instead of zero.
>
> (tClob is temporary CLOB and cStmt is CallableStatement)
>
> You probably don't want to change your working code, but if you have
> your previous proofs of concept, can you please try to use 1 instead
> of 0 in the Clob.setString() call? I'm sure I definitely saw yours
> "Invalid operation exceptions" during the development of my
> "framework" :-/
>
> Thank you very much!
>
> Have a nice night
>
> PETR
>
>
> On Tue, Jul 1, 2008 at 19:38, <glassfish_at_javadesktop.org> wrote:
>> Hi again
>>
>> I've already got the way to update the content of clob object.
>>
>> try {
>> clob = createClob(cn);
>> Writer wr = clob.setCharacterStream(0);
>> wr.write(xml);
>> wr.flush();
>> wr.close();
>> psUpd.setClob(2, clob);
>> } catch (Exception gg) {
>> gg.printStackTrace();
>> }
>>
>> Best regards
>> Aniceto Perez
>> [Message sent by forum member 'aperezymadrid' (aperezymadrid)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=283729
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>