pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
11+ messages / 3 participants
[nested] [flat]

* JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-19 19:31  Michael musset <mickamusset@gmail.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Michael musset @ 2010-10-19 19:31 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

I'm having trouble of inserting an SQLXML  in my Postgresql 8.4 database :

java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML cannot be
cast to [B
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2ResultSet.java:1729)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSet.java:1291)

when i use that :

SQLXML sqlxml = con.createSQLXML();
DOMResult domResult=sqlxml.setResult(DOMResult.class)
domResult.setNode(xmldocumentDOM);

stmt.setSQLXML(1, sqlxml);
stmt.execute();

Do you have an idea, why ?



Thank you very much for your futur help :)

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-21 08:21  Kris Jurka <books@ejurka.com>
  parent: Michael musset <mickamusset@gmail.com>
  0 siblings, 3 replies; 11+ messages in thread

From: Kris Jurka @ 2010-10-21 08:21 UTC (permalink / raw)
  To: Michael musset <mickamusset@gmail.com>; +Cc: pgsql-jdbc



On Tue, 19 Oct 2010, Michael musset wrote:

> java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML cannot be
> cast to [B
> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2Re
> sultSet.java:1729)
> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSe
> t.java:1291)
> 
> SQLXML sqlxml = con.createSQLXML();
> DOMResult domResult=sqlxml.setResult(DOMResult.class)
> domResult.setNode(xmldocumentDOM);
> 
> stmt.setSQLXML(1, sqlxml);
> stmt.execute();
>

Your sample code and stacktrace don't seem to match, but I see what the 
problem is.  The updatable ResultSet code isn't prepared for handling a 
SQLXML object.  It's slightly tricky to fix because the code in question 
is in a JDBC2 class while SQLXML is JDBC4 only.  I'll look into it.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Fwd: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-21 08:26  Michael musset <mickamusset@gmail.com>
  parent: Kris Jurka <books@ejurka.com>
  2 siblings, 0 replies; 11+ messages in thread

From: Michael musset @ 2010-10-21 08:26 UTC (permalink / raw)
  To: pgsql-jdbc

---------- Forwarded message ----------
From: Michael musset <mickamusset@gmail.com>
Date: Thu, Oct 21, 2010 at 10:26 AM
Subject: Re: [JDBC] JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
To: Kris Jurka <books@ejurka.com>


Thank you very much, and about that :

Yes the bug appeared when I do an updaterow() to the resultset.


i've decided to migrate to postgresql 9.

will it work with JDBC4 Postgresql Driver, Version
9.0-801<http://jdbc.postgresql.org/download/postgresql-9.0-801.jdbc4.jar;?

thanks,


On Thu, Oct 21, 2010 at 10:21 AM, Kris Jurka <books@ejurka.com> wrote:

>
>
> On Tue, 19 Oct 2010, Michael musset wrote:
>
>  java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML cannot be
>> cast to [B
>>
>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2Re
>> sultSet.java:1729)
>>
>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSe
>> t.java:1291)
>>
>>
>> SQLXML sqlxml = con.createSQLXML();
>> DOMResult domResult=sqlxml.setResult(DOMResult.class)
>> domResult.setNode(xmldocumentDOM);
>>
>> stmt.setSQLXML(1, sqlxml);
>> stmt.execute();
>>
>>
> Your sample code and stacktrace don't seem to match, but I see what the
> problem is.  The updatable ResultSet code isn't prepared for handling a
> SQLXML object.  It's slightly tricky to fix because the code in question is
> in a JDBC2 class while SQLXML is JDBC4 only.  I'll look into it.
>
> Kris Jurka
>



-- 
Michael Musset,
Tel: 06 26 06 29 89




-- 
Michael Musset,
Tel: 06 26 06 29 89

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 03:53  Michael musset <mickamusset@gmail.com>
  parent: Kris Jurka <books@ejurka.com>
  2 siblings, 1 reply; 11+ messages in thread

From: Michael musset @ 2010-10-23 03:53 UTC (permalink / raw)
  To: Kris Jurka <jurka@ejurka.com>; pgsql-jdbc

So, what I have to do ?

i've tried to convert my xml into String but it still doesn't work :

ret.updateString("DATA", myXmlString);


the error appear when i did a updaterow in my resultset


the error is:

org.postgresql.util.PSQLException: ERROR: column "DATA" is of type xml but
expression is of type character varying
  Hint: You will need to rewrite or cast the expression.


how can i do that ?

thanks for the help,

On Thu, Oct 21, 2010 at 10:27 AM, Kris Jurka <jurka@ejurka.com> wrote:

>
> No it won't work with the 9.0 JDBC driver either.  The same problem exists
> in both versions.
>
> Kris
>
>
> On 10/21/2010 1:26 AM, Michael musset wrote:
>
>> Thank you very much, and about that :
>>
>> Yes the bug appeared when I do an updaterow() to the resultset.
>>
>>
>> i've decided to migrate to postgresql 9.
>>
>> will it work with JDBC4 Postgresql Driver, Version 9.0-801
>> <http://jdbc.postgresql.org/download/postgresql-9.0-801.jdbc4.jar; ?
>>
>>
>> thanks,
>>
>> On Thu, Oct 21, 2010 at 10:21 AM, Kris Jurka <books@ejurka.com
>> <mailto:books@ejurka.com>> wrote:
>>
>>
>>
>>    On Tue, 19 Oct 2010, Michael musset wrote:
>>
>>        java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML
>>        cannot be
>>        cast to [B
>>
>>  atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2Re
>>        sultSet.java:1729)
>>
>>  atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSe
>>        t.java:1291)
>>
>>
>>        SQLXML sqlxml = con.createSQLXML();
>>        DOMResult domResult=sqlxml.setResult(DOMResult.class)
>>        domResult.setNode(xmldocumentDOM);
>>
>>        stmt.setSQLXML(1, sqlxml);
>>        stmt.execute();
>>
>>
>>    Your sample code and stacktrace don't seem to match, but I see what
>>    the problem is.  The updatable ResultSet code isn't prepared for
>>    handling a SQLXML object.  It's slightly tricky to fix because the
>>    code in question is in a JDBC2 class while SQLXML is JDBC4 only.
>>      I'll look into it.
>>
>>    Kris Jurka
>>
>>
>>
>>
>> --
>> Michael Musset,
>> Tel: 06 26 06 29 89
>>
>>


-- 
Michael Musset,
Tel: 06 26 06 29 89

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 04:09  Craig Ringer <craig@postnewspapers.com.au>
  parent: Michael musset <mickamusset@gmail.com>
  0 siblings, 2 replies; 11+ messages in thread

From: Craig Ringer @ 2010-10-23 04:09 UTC (permalink / raw)
  To: Michael musset <mickamusset@gmail.com>; +Cc: Kris Jurka <jurka@ejurka.com>; pgsql-jdbc

On 23/10/2010 11:53 AM, Michael musset wrote:
> So, what I have to do ?
>
> i've tried to convert my xml into String but it still doesn't work :
>
> ret.updateString("DATA", myXmlString);
>
>
> the error appear when i did a updaterow in my resultset
>
>
> the error is:
>
> org.postgresql.util.PSQLException: ERROR: column "DATA" is of type xml
> but expression is of type character varying
>    Hint: You will need to rewrite or cast the expression.

It's one of those irritating areas where PostgreSQL's overzealous 
refusal to cast ::text or ::varchar for interpretation as literals of 
another type bites you.

You need to use updateObject("DATA", java.sql.Types.SQLXML) so the JDBC 
driver knows what type to specify.

-- 
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 04:20  Michael musset <mickamusset@gmail.com>
  parent: Craig Ringer <craig@postnewspapers.com.au>
  1 sibling, 1 reply; 11+ messages in thread

From: Michael musset @ 2010-10-23 04:20 UTC (permalink / raw)
  To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: Kris Jurka <jurka@ejurka.com>; pgsql-jdbc

Thanks,

sorry for my poor level in Java/JDBC :

but how do you use that ?

i've tried :

ret.updateObject("DATA",writer.toString() ,java.sql.Types.SQLXML);

but it's still doesn't work :

ERROR: column "DATA" is of type xml but expression is of type character
varying
  Hint: You will need to rewrite or cast the expression.


neither this one :

ret.updateObject("DATA",(java.sql.Types.SQLXML)writer.toString());


sorry,

On Sat, Oct 23, 2010 at 6:09 AM, Craig Ringer
<craig@postnewspapers.com.au>wrote:

> On 23/10/2010 11:53 AM, Michael musset wrote:
>
>> So, what I have to do ?
>>
>> i've tried to convert my xml into String but it still doesn't work :
>>
>> ret.updateString("DATA", myXmlString);
>>
>>
>> the error appear when i did a updaterow in my resultset
>>
>>
>> the error is:
>>
>> org.postgresql.util.PSQLException: ERROR: column "DATA" is of type xml
>> but expression is of type character varying
>>   Hint: You will need to rewrite or cast the expression.
>>
>
> It's one of those irritating areas where PostgreSQL's overzealous refusal
> to cast ::text or ::varchar for interpretation as literals of another type
> bites you.
>
> You need to use updateObject("DATA", java.sql.Types.SQLXML) so the JDBC
> driver knows what type to specify.
>
> --
> Craig Ringer
>
> Tech-related writing at http://soapyfrogs.blogspot.com/
>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 04:34  Michael musset <mickamusset@gmail.com>
  parent: Michael musset <mickamusset@gmail.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Michael musset @ 2010-10-23 04:34 UTC (permalink / raw)
  To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: Kris Jurka <jurka@ejurka.com>; pgsql-jdbc

Ok, this one is a little bit stupid :

ret.updateObject("DATA",(java.sql.Types.SQLXML)writer.toString());


by the way, i'm using :

/postgresql-9.0-801.jdbc4.jar ( i thought that it is better to use
postgresql 9 )

thx,


On Sat, Oct 23, 2010 at 6:20 AM, Michael musset <mickamusset@gmail.com>wrote:

> Thanks,
>
> sorry for my poor level in Java/JDBC :
>
> but how do you use that ?
>
> i've tried :
>
> ret.updateObject("DATA",writer.toString() ,java.sql.Types.SQLXML);
>
> but it's still doesn't work :
>
>
> ERROR: column "DATA" is of type xml but expression is of type character
> varying
>   Hint: You will need to rewrite or cast the expression.
>
>
> neither this one :
>
> ret.updateObject("DATA",(java.sql.Types.SQLXML)writer.toString());
>
>
> sorry,
>
>
> On Sat, Oct 23, 2010 at 6:09 AM, Craig Ringer <craig@postnewspapers.com.au
> > wrote:
>
>> On 23/10/2010 11:53 AM, Michael musset wrote:
>>
>>> So, what I have to do ?
>>>
>>> i've tried to convert my xml into String but it still doesn't work :
>>>
>>> ret.updateString("DATA", myXmlString);
>>>
>>>
>>> the error appear when i did a updaterow in my resultset
>>>
>>>
>>> the error is:
>>>
>>> org.postgresql.util.PSQLException: ERROR: column "DATA" is of type xml
>>> but expression is of type character varying
>>>   Hint: You will need to rewrite or cast the expression.
>>>
>>
>> It's one of those irritating areas where PostgreSQL's overzealous refusal
>> to cast ::text or ::varchar for interpretation as literals of another type
>> bites you.
>>
>> You need to use updateObject("DATA", java.sql.Types.SQLXML) so the JDBC
>> driver knows what type to specify.
>>
>> --
>> Craig Ringer
>>
>> Tech-related writing at http://soapyfrogs.blogspot.com/
>>
>
>


-- 
Michael Musset,
Tel: 06 26 06 29 89

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 06:24  Kris Jurka <books@ejurka.com>
  parent: Craig Ringer <craig@postnewspapers.com.au>
  1 sibling, 0 replies; 11+ messages in thread

From: Kris Jurka @ 2010-10-23 06:24 UTC (permalink / raw)
  To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: Michael musset <mickamusset@gmail.com>; pgsql-jdbc


On Sat, 23 Oct 2010, Craig Ringer wrote:

> You need to use updateObject("DATA", java.sql.Types.SQLXML) so the JDBC 
> driver knows what type to specify.
>

That's not the API for update object.  There isn't a type parameter, the 
variant with a third int parameter is a scale for numeric data.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 06:25  Kris Jurka <books@ejurka.com>
  parent: Kris Jurka <books@ejurka.com>
  2 siblings, 2 replies; 11+ messages in thread

From: Kris Jurka @ 2010-10-23 06:25 UTC (permalink / raw)
  To: Michael musset <mickamusset@gmail.com>; +Cc: pgsql-jdbc



On Thu, 21 Oct 2010, Kris Jurka wrote:

> On Tue, 19 Oct 2010, Michael musset wrote:
>
>> java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML cannot be
>> cast to [B
>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2Re
>> sultSet.java:1729)
>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSe
>> t.java:1291)
>> 
>> SQLXML sqlxml = con.createSQLXML();
>> DOMResult domResult=sqlxml.setResult(DOMResult.class)
>> domResult.setNode(xmldocumentDOM);
>> 
>> stmt.setSQLXML(1, sqlxml);
>> stmt.execute();
>> 
>
> Your sample code and stacktrace don't seem to match, but I see what the 
> problem is.  The updatable ResultSet code isn't prepared for handling a 
> SQLXML object.  It's slightly tricky to fix because the code in question is 
> in a JDBC2 class while SQLXML is JDBC4 only.  I'll look into it.
>

I've put a fix for this into CVS.  I've uploaded a new jar file here:

http://ejurka.com/pgsql/jars/xml/

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 10:30  Michael musset <mickamusset@gmail.com>
  parent: Kris Jurka <books@ejurka.com>
  1 sibling, 0 replies; 11+ messages in thread

From: Michael musset @ 2010-10-23 10:30 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

THANK YOU !

On Sat, Oct 23, 2010 at 8:25 AM, Kris Jurka <books@ejurka.com> wrote:

>
>
> On Thu, 21 Oct 2010, Kris Jurka wrote:
>
>  On Tue, 19 Oct 2010, Michael musset wrote:
>>
>>  java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML cannot be
>>> cast to [B
>>>
>>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2Re
>>> sultSet.java:1729)
>>>
>>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSe
>>> t.java:1291)
>>>
>>> SQLXML sqlxml = con.createSQLXML();
>>> DOMResult domResult=sqlxml.setResult(DOMResult.class)
>>> domResult.setNode(xmldocumentDOM);
>>>
>>> stmt.setSQLXML(1, sqlxml);
>>> stmt.execute();
>>>
>>>
>> Your sample code and stacktrace don't seem to match, but I see what the
>> problem is.  The updatable ResultSet code isn't prepared for handling a
>> SQLXML object.  It's slightly tricky to fix because the code in question is
>> in a JDBC2 class while SQLXML is JDBC4 only.  I'll look into it.
>>
>>
> I've put a fix for this into CVS.  I've uploaded a new jar file here:
>
> http://ejurka.com/pgsql/jars/xml/
>
> Kris Jurka
>



-- 
Michael Musset,
Tel: 06 26 06 29 89

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
@ 2010-10-23 11:42  Michael musset <mickamusset@gmail.com>
  parent: Kris Jurka <books@ejurka.com>
  1 sibling, 0 replies; 11+ messages in thread

From: Michael musset @ 2010-10-23 11:42 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

One thing that i regret about SQLXML object, is that you can't do at the
same time :


1) get an SQLXML Object from a resultset
2) modify It
3) update the SQLXML Object to the resultset
4) updaterow


I've tried this :

// retrieve an SQLXML object from the ResultSet:
SQLXML sqlxml = resultSet.getSQLXML(1); // 1 is the column index
// obtain DOM tree from SQLXML object:
DOMSource source = sqlxml.getSource(DOMSource.class);

// create document object from DOMSource:
Document document = (Document) source.getNode();

modify the document here

resultSet.setSQLXML(1,sqlxml );
resultSet.updaterow();



but it doesn't work.

If someone is interesting about getting data and updating data in xml.

my method is to get a string from my xml.
parse it
modify the data

and :


SQLXML sqlxml = con.createSQLXML();
DOMResult domResult=sqlxml.setResult(DOMResult.class)
domResult.setNode(xmldocumentDOM);
stmt.setSQLXML(1, sqlxml);
stmt.execute();

It's work .... but it's not beautiful ......



anyway, thank for the help !






On Sat, Oct 23, 2010 at 8:25 AM, Kris Jurka <books@ejurka.com> wrote:

>
>
> On Thu, 21 Oct 2010, Kris Jurka wrote:
>
>  On Tue, 19 Oct 2010, Michael musset wrote:
>>
>>  java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4SQLXML cannot be
>>> cast to [B
>>>
>>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2Re
>>> sultSet.java:1729)
>>>
>>> atorg.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSe
>>> t.java:1291)
>>>
>>> SQLXML sqlxml = con.createSQLXML();
>>> DOMResult domResult=sqlxml.setResult(DOMResult.class)
>>> domResult.setNode(xmldocumentDOM);
>>>
>>> stmt.setSQLXML(1, sqlxml);
>>> stmt.execute();
>>>
>>>
>> Your sample code and stacktrace don't seem to match, but I see what the
>> problem is.  The updatable ResultSet code isn't prepared for handling a
>> SQLXML object.  It's slightly tricky to fix because the code in question is
>> in a JDBC2 class while SQLXML is JDBC4 only.  I'll look into it.
>>
>>
> I've put a fix for this into CVS.  I've uploaded a new jar file here:
>
> http://ejurka.com/pgsql/jars/xml/
>
> Kris Jurka
>



-- 
Michael Musset,
Tel: 06 26 06 29 89

^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2010-10-23 11:42 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-19 19:31 JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar Michael musset <mickamusset@gmail.com>
2010-10-21 08:21 ` Kris Jurka <books@ejurka.com>
2010-10-21 08:26   ` Michael musset <mickamusset@gmail.com>
2010-10-23 03:53   ` Michael musset <mickamusset@gmail.com>
2010-10-23 04:09     ` Craig Ringer <craig@postnewspapers.com.au>
2010-10-23 04:20       ` Michael musset <mickamusset@gmail.com>
2010-10-23 04:34         ` Michael musset <mickamusset@gmail.com>
2010-10-23 06:24       ` Kris Jurka <books@ejurka.com>
2010-10-23 06:25   ` Kris Jurka <books@ejurka.com>
2010-10-23 10:30     ` Michael musset <mickamusset@gmail.com>
2010-10-23 11:42     ` Michael musset <mickamusset@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox