Feedback
Did this article resolve your question/issue?

   

Article

Can’t query XML data types on Oracle 11.2 and 12c with Connect for JDBC

« Go Back

Information

 
TitleCan’t query XML data types on Oracle 11.2 and 12c with Connect for JDBC
URL Name000027848
Article Number000152022
EnvironmentProduct : Connect for JDBC Oracle driver
Version : 4.2, 5.0
OS : Java
Database : Oracle 11.2 and 12c
Application : All supported applications
Question/Problem Description
When querying Oracle XML datatypes columns from an Oracle 11.2 and 12c database an error occurs and no data is returned.

Note :
There is no problem creating the column.
There is no problem inserting the data.
The problem does not occur with Oracle 11.1.
Steps to Reproduce
Clarifying Information
Steps to reproduce:
  1. CREATE TABLE mytable (  Col1 XMLTYPE )
  2. INSERT INTO mytable  VALUES ( XMLType('<Column No="123">  <Building>ABCDEF</Building> </Warehouse>'))
  3. SELECT Col1 FROM mytable
Error Messagejava.sql.SQLException: [DataDirect][Oracle JDBC Driver]This column type is not currently supported by this driver.
Defect NumberDefect DD00064437
Enhancement Number
Cause
Oracle changed the default storage type for the XMLTYPE data type. When a column is created with data type of XMLTYPE with no storage specification, it is created by the server using the default storage model. The default storage model changed from CLOB in 11.2.0.1.0 to binary in 11.2.0.2.0. The Oracle documentation states the following:

The default XMLType storage model is used if you do not specify a storage model when you create an XMLType table or column. Prior to Oracle Database 11g Release 2 (11.2.0.2), unstructured (CLOB) storage was used by default. The default storage model is now binary XML storage.
(Reference at http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/whatsnew.htm)

The DataDirect Oracle JDBC driver supports the XMLTYPE data type, but only certain "flavors" of that data type. When creating an XMLTYPE column, it is possible to specify different storage types, whether or not an xml schema definition is tied to the column, etc. The driver does NOT support all such combinations of XMLTYPE. One of the unsupported "flavors" of XMLTYPE is one for which binary storage, which is now the default in Oracle 11.2.2. The DataDirect driver supports CLOB storage but does not support binary storage.
Resolution
Defect DD00064437 has been rejected because the driver does not support binary storage of the XMLTYPE


 
Workaround
There are 2 options to workaround this issue.
  1. At table creation CLOB storage for XMLTYPE columns can be specified. This allows the driver to properly retrieve the contents of such columns.

    For example:
    CREATE TABLE mytable (Col1 XMLTYPE)

    If the statement is revised to the following, the reported problem is circumvented:

    CREATE TABLE mytable (Col1 number XMLTYPE) XMLTYPE Col1 STORE AS CLOB
     
  2. Use only if modifying the table is not an option. The CREATE TABLE statement can be left alone, without the "STORE AS CLOB" clause. The select statement which attempts to retrieve the contents of the XMLTYPE column, the Oracle TO_CLOB function can be used.
 

For example:
SELECT Col1 from mytable

can be changed to:

SELECT  TO_CLOB(Col1) from mytable

The use of the TO_CLOB method forces the server to return the value as a CLOB, which the driver is well equipped handle.

Notes
Last Modified Date9/13/2015 3:54 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.