Java: Oracle XMLType + JDBC

How can I get oracle XMLElement to JDBC?

java.sql.Statement st = connection.createStatement(); // works
oracle.jdbc.OracleResultSet rs = st.execute("SELECT XMLElement("name") FROM dual");
rs.getString(1); // returns null, why?
oracle.sql.OPAQUE = (OPAQUE) rs.getObject(1); // this works, but wtf is OPAQUE ?

Basically, I want to read String like <name> </name> or whatever XML formatted output. But I always fail to cast output to anything reasonable. Only weird oracle.sql.OPAQUE works, but I totally dont know what to do with that. Even toString() is not overriden!

Any ideas? How to read Oracle's (I am using Oracle 10.0.2) XMLElement (XMLType) ?

Answers


You can't. Oracle's JDBC driver does not support the JDBC XML type properly.

The only thing you can do, is to convert the XML as part of the query:

SELECT to_clob(XMLElement("name")) from dual

Then you can retrieve the XML using getString()

alternatively you can also use XMLElement("name").getClobVal(), but again this is part of your query and it can be accessed as a String from within your Java class


Need Your Help

how to retrieve data from field name and column to generate graph

php mysql

so the following code is what I am using to try to generate a graph using pchart. I have been able to generate some of the graph. The graph at the moment looks like this:

J2ME: How to generate random number?

java java-me random midp cldc

I just wanted to know how do I generate random number using J2ME CLDC 1.0 MIDP 2.0 ?