Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar

Поиск
Список
Период
Сортировка
От Michael musset
Тема Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
Дата
Msg-id AANLkTikXBAnKyZkTgk2AJwGAXZppZ8qYC8FSuTmxoU6O@mail.gmail.com
обсуждение исходный текст
Ответ на Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar  (Kris Jurka <books@ejurka.com>)
Список 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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Michael musset
Дата:
Сообщение: Re: JDBC4 with SQLXML and postgresql-8.4-702.jdbc4.jar
Следующее
От: dmp
Дата:
Сообщение: Re: Bug in DatabaseMetaData.getColumns() with columns based on domains