7 Replies Latest reply: Jun 7, 2013 4:40 PM by dsurber

# Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar

No matter what I try, they are always somewhat different and I'm getting exceptions with JDBC on either setSQLXML or on .getString() once I retrieved the SQLXML object and want to get the content back or I'm downright getting "oracle.xdb.XMLType cannot be cast to java.sql.SQLXML"

How is it possible that Oracle who owns Java and OracleDB can't make a working Java driver? I just want to be able to work with XML, I didn't know this was asking much. I have OracleXE installed.

• ###### 1. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
Welcome to the forum!

Whenever you post you need to provide ALL of the product and version information applicable to the question or issue you are asking about
>
No matter what I try, they are always somewhat different and I'm getting exceptions with JDBC on either setSQLXML or on .getString() once I retrieved the SQLXML object and want to get the content back or I'm downright getting "oracle.xdb.XMLType cannot be cast to java.sql.SQLXML"
>
Before you submit a question or issue use the 'Preview' tab so you can see it as it will display. Then read your entire submission and ask yourself:
>
Could I answer a question like that based ONLY on the information that was provided?
>

All you have done is complain. That is basically the equivalent of a five year old saying 'Mommy, my tummy hurts'.

>
No matter what I try
>
What did you try? You haven't posted ANY information about what you are even doing, what jars, tools or code you are doing it with or HOW you are doing it.
>
I'm getting exceptions with JDBC on either setSQLXML or on .getString() once I retrieved the SQLXML object
>
What exceptions? You haven't posted ANY exceptions or any of the code that caused those exceptions.

Retrieved WHAT SQLXML object? Retrieved from where? What is the full name and version of the database you are using? For Oracle that would be the 4 digit version as returned by 'SELECT * FROM V\$VERSION'. Oracle DB doesn't have any SQLXML objects; it has XMLTYPE columns. Is that what you are trying to access?
>
Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
>
Where did you get them from? How did you get them? How do you know that they don't match? What is the full name and version of the jars that you are using?

Have you used this functionality before? Do you know how to use it? If you have never used it and have no expertise with it we need to know that so we can tell you how to get up to speed so you can use it successfully.

Since you haven't provided ANY of the information needed to provide any specific suggestions all we can do is assume that you are using the last, current version of Java and all jars files and have never used the functionality. In that case you need to start at the beginning.

Review the relevant sections of the JDBC Developer's Guide
http://docs.oracle.com/cd/E18283_01/java.112/e16548/jdbcvers.htm#BABGHBCC
>
SQLXML Type
One of the most important updates in JDBC 4.0 standard is the support for the XML data type, defined by the SQL 2003 standard. Now JDBC offers a mapping interface to support the SQL/XML database data type, that is, java.sql.SQLXML. This new JDBC interface defines Java native bindings for XML, thus making handling of any database XML data easier and more efficient.
. . .
The oracle.jdbc.getObjectReturnsXMLType Property

In Oracle Database 10g and earlier versions of Oracle Database 11g, Oracle JDBC drivers supported the Oracle SQL XML type (XMLType) through an Oracle proprietary extension. XML values were represented by instances of the oracle.xdb.XMLType class and the SQL XMLType values were read and set through the JDBC standard getObject, setObject, and updateObject methods.

The JDBC standard requires the getObject method to return an instance of java.sql.SQLXML type when called on a SQL XML type column. But, the earlier versions of Oracle JDBC drivers return an instance of oracle.xdb.XMLType. This does not conform to the JDBC standard.

The current release of Oracle JDBC drivers conform to the JDBC standard with the introduction of a new connection property, oracle.jdbc.getObjectReturnsXMLType. If you set this property to false, then the getObject method returns an instance of java.sql.SQLXML type. You can achieve this by using the following command line option while compiling your program with javac:

-Doracle.jdbc.getObjectReturnsXMLType="false"
If you depend on the existing Oracle proprietary support for SQL XMLType using oracle.xdb.XMLType, then you can change the value of this property back to true by using the following command line option:

-Doracle.jdbc.getObjectReturnsXMLType="true"
The value of the oracle.jdbc.getObjectReturnsXMLType property is a String representing a boolean value of either true or false. If the value of this property is true, then the getObject method returns oracle.xdb.XMLType instances, when called for a SQL XMLType column. This is the deafault value of the oracle.jdbc.getObjectReturnsXMLType property. If the value of this property is false, then the getObject method returns java.sql.SQLXML instances. This is the standard JDBC-compliant mode.

Note:

The oracle.jdbc.getObjectReturnsXMLType property affects only the result of the getObject method. All other methods conform to the JDBC 4.0 standard regardless of the value of the property.
>
The exception that you are getting
>
oracle.xdb.XMLType cannot be cast to java.sql.SQLXML
>
is telling that the XMLType is NOT an SQLXML type so you can't use it as one. That doc section above should tell explain that those are two DIFFERENT types. You use one or the other depending on which version of the functionality you want to use. You can use the older 'non-JDBC' standard or the new 'JDBC' standard. But you can't mix the two.

Review that entire chapter of the doc and see if that helps.

If not then you need to provide ALL relevant information if you need more help:

1. Java version
2. DB name and version
3. JAR file names and versions
4. Java code that demonstrates the problem
5. EXACT copies of any and all exceptions and errors that occur
6. A description, in English, of what you are trying to do and how you are trying to do it.

When you post use \
 on the line before and on the line after any code to preserve formattting. See the FAQ for other formatting guidelines. Use the 'Preview' tab to see what your post will look like before you submit it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
• ###### 2. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
Wow, you managed to be courteous yet you still ripped the guy a new one there. I'm impressed.
• ###### 3. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
Hi, here is how I got a matching set of .jars and I also switched from JDK 1.7 to JDK 1.6. I don't know if that contributed, I'd have to test it.
I downloaded the ojdbc6.jar from the JDBC site matching my database version.
I downloaded the full Oracle database 11g and took xdb.jar and xmlparserv2.jar from its installation directory.

It is working now with my current testcases.

The existence of the oracle.jdbc.getObjectReturnsXMLType property is informational, thank you, although I wasn't using .getObject().
• ###### 4. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
>
I downloaded the full Oracle database 11g and took xdb.jar and xmlparserv2.jar from its installation directory.
>
Well that 11g will have several installation directories and several versions of each of those jar files.

There are THREE different xdb.jar files - they are different sizes and different versions.
D:\app\Administrator\product\11.2.0>dir /b /s xdb*.jar
D:\app\Administrator\product\11.2.0\dbhome_1\sqldeveloper\rdbms\jlib\xdb.jar
And there are FIVE files named xmlparserv2.jar and at least THREE of them are different sizes and different versions.
D:\app\Administrator\product\11.2.0>dir /b /s xmlparser*.jar
D:\app\Administrator\product\11.2.0\dbhome_1\xdk\lib\xmlparserv2.jar
Make sure you use the matching versions of those files.
• ###### 5. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
Hmm, might that be specific to your computer? I spot for example:
and "OWB" I translate to Warehouse Builder, which not everyone may have depending on which distribution of Oracle you're using (regular, enterprise, OWB is also a separate install I believe)

Still: what a mess.
• ###### 6. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
>
Hmm, might that be specific to your computer?
>
Not sure how that could be. That is from an install of vanilla 11.2.0.1.0 enterprise edition
>
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
>
That installs modules that each have their own copy of the jar files they need
>
D:\app\Administrator\product\11.2.0\dbhome_1\RDBMS\jlib\xdb.jar -- Oracle's XML DB functionality
D:\app\Administrator\product\11.2.0\dbhome_1\sqldeveloper\rdbms\jlib\xdb.jar -- Oracle's sql developer installation
>
Each of those modules has a different development team within Oracle and the teams can't always synchronize on the jar file version being used. The XML DB team 'owns' the 'xdb.jar' and controls its release cycle. The other teams have to use a released version of the jar that they have tested their own functionality with.

Similar story with the other jar file
>
D:\app\Administrator\product\11.2.0\dbhome_1\LIB\xmlparserv2.jar -- the one used by the Oracle DB itself (DBMS_METADATA package code, expdp/impdp, etc)
D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\lib\xmlparserv2.jar -- Oracle Components for Java team
D:\app\Administrator\product\11.2.0\dbhome_1\oui\jlib\xmlparserv2.jar -- Oracle Universal Installer (oui)
>
All of those jars I provided were installed as part of the generic Enterprise install.

That is why it is important to use a set of jars whose versions are compatible and not just grab a jar of a given name. If what OP (or anyone) is doing is intended to work with part of the related Oracle functionality (e.g. OC4J) then the oc4j jars should be used or you can have issues similar to what OP experienced.
>
Still: what a mess.
>
No disagreement there. It is the Java equivalent of 'DLL hell'. ;)
• ###### 7. Re: Can't get matching xdb6.jar, xmlparserv2.jar and ojdbc6.jar
991204 wrote:
Hi, here is how I got a matching set of .jars and I also switched from JDK 1.7 to JDK 1.6. I don't know if that contributed, I'd have to test it.
I downloaded the ojdbc6.jar from the JDBC site matching my database version.
I downloaded the full Oracle database 11g and took xdb.jar and xmlparserv2.jar from its installation directory.
So you have ojdbc6.jar from one version and xdb.jar and xmlparserv2.jar from another and you are surprised at a version mismatch? Get all three from the same Oracle Database version. In your case you want the latest versions of all three, 11.2.0.3.0.

Douglas