• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to use data of type XMLTYPE in database in java

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a table with different columns and one of the columns is of the type XMLTYPE. i want to retrieve data from stored procedure and use it in Java, also update it when required.

Can anyone come up suggestions, as i havent used XMLTYPE so far ? sample code will be beneficial
[ October 28, 2004: Message edited by: mvk ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"mvk",
We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks,
Jeanne
Forum Bartender
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the information. I changed my display name.

I would appreciate a solution now : x()
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which Database are you using? I'd expect you'd have to consult your DB/Driver documentation for an answer. After quick glace at my Oracle docs, it seems you use the Oracle specific Class oracle.xdb.XMLType with this data type. Probably different on other platforms, if they support this type.
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul ,

We are using Oracle Database. Per our architecture, Stored procedure will return this COLUMN of type XMLTYPE, along with other values. I would like to retrieve it along with other values. I think i might have to parse the values from the XMLTYPE data.

Again, any sample code will be helpful.

Thanks for your response
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the Oracle documentation. There is example code for using XMLType via JDBC.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to deal with XMLTYPE in JDBC code then you will have to use Oracle driver's extension -

XMLType xml = XMLType.createXML(resultSet.getOPAQUE("xmlColumn"));

There are multiple ways to deal with XMLType in your JDBC code. One is to use Oracle Specific extension as above, You can also use JAVA DOM API with Oracle extension. You can find enough examples in online documentation.

Other simple way to avoid Oracle specific extensions would be to make your stored procedure return CLOB or String for XMLType.

The Select statement in SP would look like

SELECT e.xmlColumn.getStringVal() from table e -- for String
SELECT e.xmlColumn.getClobVal() from table e -- for Clob
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic