• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use data of type XMLTYPE in database in java

 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • 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 ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for the information. I changed my display name.

I would appreciate a solution now : x()
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the Oracle documentation. There is example code for using XMLType via JDBC.
 
nilesh Katakkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic