Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XMLType Column Oracle - InsertIntoDB - Exception  RSS feed

Ravishankar Dhamodharan
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to insert a well structured XML into an XMLType Column. Please refer below for my code sinppet, table structure and Exception.
Could you please help me to over come this exception.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import oracle.jdbc.OracleCallableStatement;
import oracle.xdb.XMLType;
public class InsertEDXMLtoDB {

// Using String - byteBuffer - InputStream

public static void main (String a[]) throws FileNotFoundException

String Cit="CIT_123";
String xmlText="<PO><PONO>200</PONO><PNAME>PO_2</PNAME></PO>";

try {
Class.forName("oracle.jdbc.OracleDriver") ;
Connection conn = DriverManager.getConnection("jdbcracle:thin:@IP:1521rcl","scott", "tiger");
String statementText="insert into EdXML (CIT,XML_DOCUMENT) values(?,?)";

byte[] byteBuffer = xmlText.getBytes();
InputStream is = new ByteArrayInputStream(byteBuffer);
XMLType xml;
xml = XMLType.createXML(conn,is);

OracleCallableStatement statement = null;
statement = (OracleCallableStatement) conn.prepareCall(statementText);
statement.setString(1, LNCit);
boolean result = statement.execute();

} catch (SQLException e) {
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
} finally {

Table Structure:

SQL> desc EdXML;
Name Null? Type
----------------------------------------- -------- -----------------


Exception in thread "main" java.lang.NoSuchFieldError: conversion
at oracle.xdb.XMLType.<init>(
at oracle.xdb.XMLType.createXML(
at InsertEDXMLtoDB.main(

I tried all the code snippet availble on Net and got the same above exception. Wherein if I have the XMLTYpe Column as CLOB the above works good, but my requirement
goes with the XMLType Column.

It could be great help for me if someone suggest how to do the same with the Spring JDBC Template. [Inserting XML to XMLType Column Type using Spring JDBC Template]

Kindly help me out in this matter.
Martin Vajsar
Posts: 3752
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't ever use XMLType in Oracle, but it seems to be covered quite thoroughly in the documentation. It seems that you can bind your XML data as a CLOB and use a function to convert it into XMLTYPE in your insert statement (see example 11-15 on that page).

If you're using a JDBC driver older than 11g, you'll probably want to look up the matching documentation version.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!