How do I access XMLType using JDBC ?

This thread will address a number of issues related to accessing XMLType tables and columns from Java via JDBC.

The following code shows examples of accessing XMLType using Java getting an instance of W3C DOM interface org.w3c.dom.Document. It also shows how which DOM implementation is returned by the getDOM() method is dependant on whether or not the OCI driver or Thin Dirver is in used.
The code also show how to use the createNonSchemaBasedXMLType() method to access a schema based XMlLType via the thin driver...
public class GetXMLTypeDOM extends BaseApplication
   protected String driverType;
   protected String getDriver() {
     return this.driverType;
   public void doSomething(String[] Args) throws Exception
     OraclePreparedStatement  statement = null;
     this.driverType = this.OCI_DRIVER;
     this.initializeConnection();
     statement = (OraclePreparedStatement) getConnection().prepareStatement("select object_value from PURCHASEORDER_NSB_XMLTYPE where rownum < 2");
     getDocument(statement);
     statement = (OraclePreparedStatement) getConnection().prepareStatement("select object_value from PURCHASEORDER_SB_XMLTYPE where rownum < 2");
     getDocument(statement);
     getConnection().close();
     this.driverType = this.THIN_DRIVER;
     this.initializeConnection();
     statement = (OraclePreparedStatement) getConnection().prepareStatement("select object_value from PURCHASEORDER_NSB_XMLTYPE where rownum < 2");
     getDocument(statement);
     statement = (OraclePreparedStatement) getConnection().prepareStatement("select object_value from PURCHASEORDER_SB_XMLTYPE where rownum < 2");
     getDocument(statement);
     statement = (OraclePreparedStatement) getConnection().prepareStatement("select x.object_value.createNonSchemaBasedXML() from PURCHASEORDER_SB_XMLTYPE x where rownum < 2");
     getDocument(statement);
     getConnection().close();
   private void getDocument(OraclePreparedStatement statement)
     OracleResultSet resultSet = null;
     org.w3c.dom.Document  doc = null;
     XMLType xml = null;
     try {
       resultSet = (OracleResultSet) statement.executeQuery();
       while (resultSet.next())
          xml = (XMLType) resultSet.getObject(1);
          doc = xml.getDOM();
          System.out.println("DOM Implementation is " + doc.getClass().getName());
          xml.close();
       resultSet.close();
       statement.close();
    catch (SQLException sqle) {
        System.out.println("Caught SQL Exception : " + sqle.getMessage());
  public static void main (String[] args)
    try
      GetXMLTypeDOM example = new GetXMLTypeDOM();
      example.doSomething(args);
    catch (Exception e)
      e.printStackTrace();
}Here's the output from running this class..
C:\TEMP>
C:\Oracle\JDeveloper\jdk\bin\javaw.exe -client -classpath C:\xdb\JDeveloper\Classes;C:\Oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar;C:\Oracle\product\10.2.0\db_1\LIB\xmlparserv2.jar;C:\Oracle\product\10.2.0\db_1\RDBMS\jlib\xdb.jar;C:\xdb\JDeveloper\jakarta-slide-webdavclient-bin-2.1\lib\jakarta-slide-webdavlib-2.1.jar;C:\xdb\JDeveloper\jakarta-slide-webdavclient-bin-2.1\lib\commons-httpclient.jar;C:\xdb\JDeveloper\jakarta-slide-webdavclient-bin-2.1\lib\commons-logging.jar;C:\xdb\JDeveloper\jakarta-slide-webdavclient-bin-2.1\lib\jdom-1.0.jar -Dcom.oracle.st.xmldb.pm.ConnectionParameters=C:\\xdb\\jdeveloper\\SimpleExamples\\LocalConnection.xml -Dhttp.proxyHost=www-proxy.us.oracle.com -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts=192.168.0.77|localhost|192.168.1.1|*.oracle.com|*.us.oracle.com -Dhttps.proxyHost=www-proxy.us.oracle.com -Dhttps.proxyPort=80 -Dhttps.nonProxyHosts=192.168.0.77|localhost|192.168.1.1|*.oracle.com|*.us.oracle.com com.oracle.st.xmldb.pm.examples.GetXMLTypeDOM -mx2048M
ConnectionProvider.establishConnection(): Connecting as SCOTT/TIGER@jdbc:oracle:oci8:@(description=(address=(host=localhost)(protocol=tcp)(port=1521))(connect_data=(service_name=ORA10GR2.xp.mark.drake.oracle.com)(server=DEDICATED)))
ConnectionProvider.establishConnection(): Database Connection Established
DOM Implementation is oracle.xdb.dom.XDBDocument
DOM Implementation is oracle.xdb.dom.XDBDocument
ConnectionProvider.establishConnection(): Connecting as SCOTT/TIGER@jdbc:oracle:thin:@localhost:1521:ORA10GR2
ConnectionProvider.establishConnection(): Database Connection Established
DOM Implementation is oracle.xml.parser.v2.XMLDocument
Caught SQL Exception : Only LOB or String Storage is supported in Thin XMLType
DOM Implementation is oracle.xml.parser.v2.XMLDocument
Process exited with exit code 0.

Similar Messages

  • How do I access and use my Itunes library from a different/new computer?

    How do I access and use my Itunes library from a different/new computer?  My computer is no longer working, so I need to be able to access my library from my wife's computer.

    Your library will only be where you put it.  Copy everything from your backup copy of your old computer to the new one.
    You can redownload some itunes purchases in some countries:
    Download past purchases - Apple Support

  • How do I access and use my iTunes library on a different computer?

    How do I access and use my i Tunes library on a different computer?

    The iTunes library is only where the user puts it.  If desired to have on an additional computer, put it there by copying the ENTIRE iTunes folder from the existing computer to the new computer.

  • I have moved from a G5 Powermac to an Intel Mac Pro and am porting over Items from a Backup HDD. How can I access and use drawings and documents created on the PC computer on the Intel computer ?

    I have moved from a G5 Powermac to an Intel Mac Pro and selectively porting over items from a backup hard drive.
    How can I access and use documents and drawings created on the PC based computer ?

    Clarisworks, you need Appleworks, which will only work with Mac OS X10.6.8 or earlier.  See this tip if you must go newer.  Mac Pros with newer hardware configuration than July 20, 2011 can't use Mac OS X 10.6.8 or earlier without this tip and then it would be Mac OS X Server.  I'm not sure if the new black Mac Pro supports that configuration or not.
    iPhoto, there is an iPhoto for all versions of Mac OS X.
    iTunes, there is an iTunes for all versions of Mac OS X.  Note with iTunes versions 11 and later, which are needed for syncing with iOS 7 or or later, you will lose coverflow, if you liked that feature.  Sadly you can't run an older version of iTunes from within Mac OS X 10.9 or later.
    Sketchup: http://help.sketchup.com/en/article/60107 shows the versions that will work with intermediate Mac OS X versions, and this shows the latest version: http://help.sketchup.com/en/article/36208 be sure to click on the operating system you choose to use.
    GIF - Viewing GIFs Apple's Preview can do that.  Editing them, I like http://www.lemkesoft.com/ Graphicconverter.
    DMG is able to be opened by all versions of Mac OS X.  This are just "disk images" which store programs on a virtual disk that will open when double clicked.    Frequently you'll find the installer of the said program inside.  To find out if the program itself is compatible with 10.7 through 10.9, see http://www.roaringapps.com/
    Otherwise see the resources on:
    https://discussions.apple.com/docs/DOC-2455
    If you end up deciding to stick with Snow Leopard.

  • How can I access and use the alphabetical keyboard of the phone ?

    How can I access and use the alphabetical keyboard of the phone ? I cannot find the answer in the manual of use.  Thanks for your help !

    Recently I was abroad and tried to contact my voicemail to check my messages. I was asked to enter a password and did not know how to use the letters below the figures on the keyboard.  I had to give up and wait until I was back in my country (no password is then needed).

  • How do I access ACR using Photoshop CC?

    How do I access ACR using Photoshop CC?  Can I download the latest version of ACR for my camera and use the plug-in with Photoshop CC?  When I had CS5 I could easily access ACR.  Now I have CS6/CC I don't seem to be able to edit my images in ACR.  What do I need to do to access ACR?

    This forum is actually about the Cloud, not about using individual programs
    Once your program downloads and installs with no errors, you need the program forum
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll
    http://forums.adobe.com/community/photoshop

  • Does my macbook air have a built in virus scan?  how can I access and use it? also any recommendations of what software if this is not avail ?

    does my macbook air have a built in virus scan?  how can I access and use it? also any recommendations of what software if this is not avail ?

    Contrary to what Geeks on Hugs is telling you, Mac OS X does indeed have a basic malware scanner. It is not a feature that is directly accessible to the user, and works a bit differently than every other malware scanner out there. Gatekeeper, which has been mentioned here, is entirely separate, and provides a different method for helping to protect you against malware.
    The anti-malware scanner in Mac OS X is called XProtect. When you download an application (or any other kind of executable code), it is automatically "quarantined," so that when you open it you're asked if you really want to do that. I'm sure you're very familiar with this aspect of Mac OS X if you have ever downloaded any apps from outside the App Store. What you don't know, though, is that each time you try to open a new app, that app is checked by XProtect. If it is identified as malware, you will not be allowed to open it, and will be warned that it's malware.
    At this time, there is no known malware that can infect a properly up-to-date Mac. All current malware will be blocked by one or more methods.
    For more information, see my Mac Malware Guide.
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com.)

  • How do I access and use my iTunes gift card balance

    How do I access and use my iTunes gift card balance

    You redeem your gift card to your iTunes account.
    Then you make iTunes purchases and the amount is deducted from your account.
    See this -> iTunes 11 for Mac: Redeem an iTunes allowance, gift certificate, or Gift Card

  • How to run Excel Macros using JDBC-ODBC

    Hi,
    I want to run the excel macros in the excel file, after I connected to excel file, using JDBC-ODBC bridge.
    How macros treated here?
    Help needed please..........
    - Ramesh

    How to run Excel Macros using JDBC-ODBCYou don't.
    As my fuzzy understanding goes.....
    Macros (excel, word, etc) run via a "OLE" extension of the script host system.
    So the only way to run them is via the OLE interface. That has nothing to do with ODBC. You can write your own JNI to do that, or you might get lucky and find that someone else has written a java library to do it for you.

  • Retrieving XMLType using JDBC(THIN DRIVER)

    Oracle Database: 10g R2
    Java version: 1.4+
    Hi All,
    I have a column of type XMLType in a database table . I have to retrieve it using Oracle XDK APIs as an instance of oracle.xdb.XMLType. How to go about this using thin driver?
    Thanks

    Hello,
    Download the oracle xdk for your platform and copy the jars xdb.jar and xmlparserv2.jar from it to your classpath. Then download the latest ojdbc14.jar driver and add it to your classpath.
    Then use the following example code snippet to extract the xml from the xml-column in the resultset:
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import oracle.xdb.XMLType;
    import org.w3c.dom.Document;
    Object     object = resultSet.getObject("xmlcolumnname");
    if (object instanceof XMLType) {
         Document          document = ((XMLType)object).getDOM();
         Transformer          transformer = TransformerFactory.newInstance().newTransformer();
         transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
         transformer.setOutputProperty(OutputKeys.INDENT,"no");
         transformer.transform(new DOMSource(document),new StreamResult(System.out));
    } else {
    In your query that produces the resultset, it's important to add the procedure ".createNonSchemaBasedXML()" to your xml-value so there is no schema attached to it.
    For example: select myxmlcolumn.createNonSchemaBasedXML() as myxml from mytable;
    or select extract(myxmlcolumn,'//somexpath').createNonSchemaBasedXML() as myxml from mytable;
    Regards, Micha

  • How do I access and use my main computer over my local network ?

    I have a wireless internet connection that currently runs from the outside antenna into the house via ethernet. My internet provider is setting up a second wireless system so that a computer 1/2 mile away can share the connection. I believe they are going to run the signal from my existing antenna into a router that will connect to the ethernet wire to my house and to an access point that will shoot a signal from a second antenna to my computer 1/2 mile away.
    I'd like to know the best way to access the computer in my house from the one 1/2 mile away.
    I'd like to be able to access and use files on my home computer so that all changes are kept on it. I'd also like to access any e-mail messages that Mail has recieved.
    My ISP said that they would have to enable VPN.
    I'd like to know if enabling file sharing would be enough, or do I need this Vine program I've read about on this forum, or do I need to set my home computer up as a server, or do I need to do something else ?
    I've read about lots of stuff but don't understand any of it very well.
    Any suggestions would be appreciated.
    Thanks
    1.3 Mhz Cube   Mac OS X (10.4.9)  

    But why pay for a solution. You can do the same thing with "Share My Desktop" and "Chicken of the VNC".

  • How do I access and use an extension while in photoshop?

    I just installed extension manager CC and BlendmeIn. How do I access and search this extension while designing in photoshop CC? *When I go to Window>extensions it is not there.
    Thank you!!
    Kate

    But why pay for a solution. You can do the same thing with "Share My Desktop" and "Chicken of the VNC".

  • Creating a new access database using JDBC

    Hi Forum,
    I have a problem in hand. Let me describe the problem:
    I want to create an "access database" from java at runtime. "Access database" is file based, so for a database named test, it will have a file test.mdb.
    Now, everything's sweet and wonderful, if somebody creates an "empty access database" at the client machine and i then connect to it and create the tables i require.
    But the issue is i want to create the database at runtime (the database name and tables are determined at runtime).
    Using the JDBC:ODBC bridge driver , i am able to connect to an existing database, but any "create database" statements are not supported.
    A last ditch solution would be that i create an empty database using access and copy the file contents in the SQL server database as a a blob object. Then when i want to create a new access database at runtime, i create a file in a particular folder , with an .mdb
    extension, copy the file contents from the SQL server (i also have an SQL server connection) BLOB object, and then try to connect to the
    .mdb file.
    But this approach seems a "quick hack" and can have problems (which i can't see as of now).
    Can you suggest a better alternative for the problem.
    See the Java Sun forum at this address for a discussion of a similar problem, but sadly with no solution.
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=484731

    I have an applet that was previously connected to Oracle 9i. I am faced with connecting to MS Access temporarily for testing purposes.
    I have been unable to successfully code connection in java. I have set up the DSN and can access in SQL Worksheet in JDev.
    I saw your question regarding creating an access db, and thought you might be so kind as to help me code the connection to access!!!!
    Any help you could provide would be greatly appreciated. I have a huge application to finish with alot of sqlj already completed. Connectivity is not my area of expertise!
    Any help you could provide would be greatly appreciated!!!
    I am not sure if I have to use bridge? Am I progressing in right direction to migrating to SQL Server if need be?

  • How to call BULK COLLECT using JDBC in JSP?

    Hi
    I am using BULK COLLECT instead of CURSOR in my Stored Procedure.
    How to use these stuff in JDBC.
    If i am using CURSOR means
    cs.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CURSOR);
    is used.
    Which types i have to use?
    I am retriving morethan one record using FOR. LOOP in SP and before that
    BULK COLLECT is used in SELECT query..
    Can you give jsp code for this?
    Thanks

    you may find related sample jdbc code on otn - http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/index.html
    Best regards.

  • How to implement Oracle DWH using JDBC

    Hello,
    i'm new to the Oracle database and i'm wondering how to implement a DWH Core or Datamart System using Oracle 11g Express. How can i "switch" a relational oracle database to a dimensional one, preparing it for OLAP/BI queries´, preferably using the JDBC interface ?
    Thanks a lot!

    An good introduction to Oracle OLAP is found on the OTN site: Oracle OLAP.
    --Ken Chin

Maybe you are looking for

  • Unable to install iTunes 8.1.1 for windows vista home premium 32 bit

    When program is installing from version 7.3, a message comes up stating I have a newer version of QuickTime which is impossible. Having purchased a new iPod Nano I cannot use it because iTunes 8.1.1 has not worked out bugs, or so it seems, to downloa

  • Assign vendor payment doc no with check lot.

    How can I get printout directly when vendor payment will happen? Is it possible? Regards, Ananda

  • Time Sheet - Data Entry Profile(T-Code CAT2)

    Hi All, I have 4 data entry profiles in the system and will like to delete 2 of them as they are no longer required. If somebody had booked time (in past) by using the profile which I want to delete, will it have any kind of impact. Please advice whe

  • CTI Connector project SAP Cloud for Customer

    Hello Experts, I am searching for the CTI Connector project used for enabling outbound calls as it is described in the SAP Cloud for Customer CTI Guide: "Download the CTI Connector project from the SAP Service Marketplace and install it." Unfortunate

  • Option to not create a shortcut when installing an AIR application

    Hello Adobe AIR community, Does anyone know if there is an option to not create a shortcut for an AIR application? Currently, all I have found is an option to choose the location of the shortcut from within the start menu (in the application descript