Any jdbc examples inserting XML doc

Newbie to xmldb/jdbc/java
I'm looking for some sample java code that uses jdbc to insert xml docs into the 10g xml db.
Also looking for sample code that does xquery using JDBC on 10g xmldb.
(using eclipse on windows)
any help appreciated

Does this help, assume that you have an instance of
public XMLType makeXMLType(OracleConnection conn,Document xmlDocument)
throws NamingException
try {
XMLType xml = null;
if (xmlDocument != null)
xml = XMLType.createXML(conn,xmlDocument);
return xml;
catch (SQLException sqle)
NamingException ne = new NamingException(SQLCache.UNEXPECTED_SQL_EXCEPTION);
ne.setRootCause(sqle);
throw ne;
You can then bind the XMLType to an insert statement using setObject.

Similar Messages

  • Problem inserting XML doc (character set)

    Hi all,
    I'm having trouble trying to insert XML either "posting" it (xsql) or "putting" it
    (OracleXML putXML).
    The error that I get: "not supported
    oracle-character-set-174".
    The environment is:
    Oracle 8i 8.1.5
    (NLS_CHARACTERSET EL8MSWIN1253 for greek)
    JDK 1.2.2
    Apache Web Server 1.3.11
    Apache JServ 1.1
    XSQL v 0.9.9.1 and
    XMLSQL, XML parser v2 that comes with it.
    I had dropped all java classes and reloaded
    them using oraclexmlsqlload batch file.
    But still getting the same error.
    The thing that is that I am
    able to insert XML doc that was generated
    with an authoring tool called W4F that extracts data from HTML pages and map them to
    XML document, even with greek characters
    in it. But when XML is generated using
    an editor or the servlet like the following:
    newschedule.xsql like
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="latestschedules.xsl"?>
    <page connection="dtv" xmlns:xsql="urn:oracle-xsql">
    <xsql:insert-request date-format="DD'/'MM'/'YYYY" table="schedule_details_view"
    transform="request-to-newschedule.xsl"/>
    <xsql:query table="schedule"
    tag-case="lower" max-rows="5" rowset-element="latestschedules"
    row-element="schedule">
    select *
    from schedules
    order by schedule_id desc
    </xsql:query>
    </page>
    request-to-newschedule.xsl like
    <?xml version = '1.0'?>
    <ROWSET xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
    <xsl:for-each select="request/parameters">
    <ROW>
    <SCHEDULE_ID><xsl:value-of select="Schedule_id_field"/></SCHEDULE_ID>
    <DESCRIPTION><xsl:value-of select="Description_field"/></DESCRIPTION>
    <DETAILS>
    <DETAILS_ITEM>
    <STARTING_TIME><xsl:value-of select="Starting_Time_field_1"/></STARTING_TIME>
    <DURATION><xsl:value-of select="Duration_field_1"/></DURATION>
    </DETAILS_ITEM>
    <DETAILS_ITEM>
    <STARTING_TIME><xsl:value-of select="Starting_Time_field_2"/></STARTING_TIME>
    <DURATION><xsl:value-of select="Duration_field_2"/></DURATION>
    </DETAILS_ITEM>
    <DETAILS_ITEM>
    <STARTING_TIME><xsl:value-of select="Starting_Time_field_3"/></STARTING_TIME>
    <DURATION><xsl:value-of select="Duration_field_3"/></DURATION>
    </DETAILS_ITEM>
    <DETAILS_ITEM>
    <STARTING_TIME><xsl:value-of select="Starting_Time_field_4"/></STARTING_TIME>
    <DURATION><xsl:value-of select="Duration_field_4"/></DURATION>
    </DETAILS_ITEM>
    <DETAILS_ITEM>
    <STARTING_TIME><xsl:value-of select="Starting_Time_field_5"/></STARTING_TIME>
    <DURATION><xsl:value-of select="Duration_field_5"/></DURATION>
    </DETAILS_ITEM>
    </DETAILS>
    </ROW>
    </xsl:for-each>
    </ROWSET>
    Hope that someone could help me on this ...
    Any advice is highly appreciated.
    Thanks in advance
    Nicos Gabrielides
    email: [email protected]

    Hi,
    How about applying an XSL on the existing XML doc to create another XML doc to filter out the table column not found in the target db table, so that all the columns are matched and then use putXML to load?
    Hope that helps.
    OTN team@IDC

  • Problem inserting xml doc into tables

    I'm trying to load and xml doc into a table/columns using putXML. I clearly have elements in my xml doc that I do not want to load into the table. I am receiving the following error: The XML element tag 'VERB' does not match the name of any of the columns/attributes of the target database. I'm having difficulty figuring out how to exclude of ignore these elements.
    Any help would be greatly appreciated.
    Thanks,
    John

    Hi,
    How about applying an XSL on the existing XML doc to create another XML doc to filter out the table column not found in the target db table, so that all the columns are matched and then use putXML to load?
    Hope that helps.
    OTN team@IDC

  • 10g XE WebDav does not load XML doc

    Hi,
    I am experimenting with XE XMLDB. I have successfully registered a simple schema and was able to insert XML doc from sqlplus into XML DB. But when I drop a XML doc into the WebDav folder, the document did not get loaded. My 10g XE is installed on my laptop running Win XP, and I have both ftp (2100) and http (8080) ports actived. everything is local in my laptop.
    I had no problem at all when (doing the same testing) dropping the the doc into another WebDAV folder, which points to the XML DB on an ora92 EE installation running on a UNIX server.
    Don't know What i have missed?

    The following command will also do the trick without bouncing your database:
    alter system register;

  • Repository event handler doesn't work when inserting an xml-doc via ftp

    Hi,
    I want to add a 'schemaLocation'-attribute to an XML-document when I load it in the repository. Therefore, I use the precreate-repository event and created a Repository Event Handler (see code extract below).
    Everything works fine if I type the following code in SQL Plus:
    Declare
    v_return BOOLEAN;
    Begin
    v_return:=DBMS_XDB.createresource('/public/xml/test.xml', XMLType(bfilename('XMLDIR', 'test.xml'),nls_charset_id('AL32UTF8')));
    end;Unfortunately, when I try to insert an XML-document via ftp into the /public/xml folder it doesn´t work as expected and no 'schemaLocation'-attribute is added to the new resource.
    What's the reason for this strange behavior and how can I solve it?
    For your information: I use the Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
    Thank you very much for your help!!!
    Repository Event Handler code extract:_
    create or replace
    PACKAGE BODY schemalocation AS
    PROCEDURE handlePreCreate (eventObject DBMS_XEVENT.XDBRepositoryEvent) AS
    XDBResourceObj DBMS_XDBRESOURCE.XDBResource;
    var XMLType;
    l_return BOOLEAN;
    l_xmldoc dbms_xmldom.DOMDocument;
    l_docelem dbms_xmldom.DOMElement;
    l_attr dbms_xmldom.DOMAttr;
    c1 clob;
    node     dbms_xmldom.DOMNode;
    txid varchar2(100);
    dDoc DBMS_XMLDOM.DOMDocument;
    nlNodeList DBMS_XMLDOM.DOMNodeList;
    BEGIN
    XDBResourceObj := DBMS_XEVENT.getResource(eventObject);
    dbms_lob.createTemporary(c1,TRUE);
    var:=DBMS_XDBRESOURCE.getcontentxml(XDBResourceObj);
    l_xmldoc := dbms_xmldom.newDOMDocument(var);
    l_docelem := DBMS_XMLDOM.getDocumentElement(l_xmldoc);
    ------ add schemaLocation attribute
    l_attr := DBMS_XMLDOM.createAttribute(l_xmldoc, 'xsi:schemaLocation');
    DBMS_XMLDOM.setValue(l_attr, 'urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd');
    l_attr := DBMS_XMLDOM.setAttributeNode(l_docelem, l_attr);
    DBMS_XMLDOM.WRITETOCLOB(l_xmldoc, c1);
    ------- get the value of the TxId-tag
    dDoc := DBMS_XMLDOM.NEWDOMDOCUMENT(c1);
    nlNodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(dDoc, 'TxId');
    node := DBMS_XMLDOM.ITEM(nlNodeList, 0);
    txid:= dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(node));
    l_return:=DBMS_XDB.createresource('/public/ok/'||txid||'.xml', XMLType(c1));
    END;

    Marco,
    Here's an example of the problem :
    create or replace package handle_events
    as
      procedure handlePreCreate(p_event dbms_xevent.XDBRepositoryEvent);
    end;
    create or replace package body handle_events
    is
    procedure handlePreCreate (p_event dbms_xevent.XDBRepositoryEvent)
    is
      XDBResourceObj dbms_xdbresource.XDBResource;
      doc XMLType;
      res boolean;
    begin
      XDBResourceObj := dbms_xevent.getResource(p_event);
      doc := dbms_xdbresource.getContentXML(XDBResourceObj);
      select insertchildxml(
        doc
      , '/root'
      , '@xsi:schemaLocation'
      , 'urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd'
      , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
      into doc
      from dual;
      res := dbms_xdb.CreateResource('/public/xml/result.xml', doc);
    end;
    end;
    declare
    res boolean;
    begin
    res := dbms_xdb.CreateFolder('/public');
    res := dbms_xdb.CreateFolder('/public/tmp');
    res := dbms_xdb.CreateFolder('/public/xml');
    end;
    declare
    res            boolean;
    resconfig      xmltype;
    my_schema      varchar2(30) := 'DEV';
    resconfig_path varchar2(300) := '/public/ResConfig.xml';
    resource_path  varchar2(300) := '/public/tmp';
    begin
      resconfig  := xmltype(
    '<ResConfig xmlns="http://xmlns.oracle.com/xdb/XDBResConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/XDBResConfig.xsd http://xmlns.oracle.com/xdb/XDBResConfig.xsd">
      <event-listeners set-invoker="true">
        <listener>
          <description>My event handler</description>
          <schema>'||my_schema||'</schema>
          <source>HANDLE_EVENTS</source>
          <language>PL/SQL</language>
          <events>
            <Pre-Create/>
          </events>
          <pre-condition>
            <existsNode>
              <XPath>/r:Resource[r:ContentType="text/xml"]</XPath>
              <namespace>xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd"</namespace>
            </existsNode>
          </pre-condition>
        </listener>
      </event-listeners>
      <defaultChildConfig>
        <configuration>
          <path>'||resconfig_path||'</path>
        </configuration>
      </defaultChildConfig>
    </ResConfig>'
      res := dbms_xdb.CreateResource(resconfig_path, resconfig);
      dbms_resconfig.addResConfig(resource_path, resconfig_path, null);
    end;
    /Giving the following input XML file :
    <?xml version="1.0" encoding="utf-8"?>
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>This works :
    SQL> declare
      2    res boolean;
      3  begin
      4    res := dbms_xdb.CreateResource('/public/tmp/test.xml',
      5               xmltype(bfilename('TEST_DIR','test.xml'), nls_charset_id('AL32UTF8')));
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> select XMLSerialize(document xdburitype('/public/xml/result.xml').getXML()
    as clob indent size = 2)  result
      2  from dual
      3  ;
    RESULT
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
    urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd
    "/>With the same document loaded via FTP, we get :
    SQL> select XMLSerialize(document xdburitype('/public/xml/result.xml').getXML()
    as clob indent size = 2)  result
      2  from dual
      3  ;
    ERROR:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00283: document encoding is UTF-16-based but default input encoding is not
    Error at line 1
    no rows selectedand the content looks like :
    < ? x m l   v e r s i o n = " 1 . 0 "   e n c o d i n g = " u t f - 8 " ? >
    < r o o t   x m l n s : x s i = " h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a - i n s t a n c e " / >As a workaround, I've found that serializing and re-parsing the document solves the problem :
      select insertchildxml(
        xmltype(doc.getclobval())
      , '/root'
      , '@xsi:schemaLocation'
      , 'urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd'
      , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
      into doc
      from dual;
    ...We then get the expected result after FTP transfer :
    SQL> select XMLSerialize(document xdburitype('/public/xml/result.xml').getXML()
    as clob indent size = 2)  result
      2  from dual
      3  ;
    RESULT
    <?xml version="1.0" encoding="UTF-8"?>
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
    urn:iso:std:iso:20022:tech:xsd:sese.023.001.01 http://www.test.com/Testswift.xsd
    "/>The workaround also works for the DOM version presented above.
    Any ideas?

  • Problem with XML doc inserting into oracle 10g

    Hi Guys, I have some knowledge in oracle 10g.
    We are doing an application, when we were trying to insert XML document (I was trying to insert XML as un-structured way.) into oracle 10g as a datatype called XMLTYPE column.
    My XML is having namespace attributes(Target namespaces) in that. So when i was trying to insert that into database , it is giving some error ,and not letting me to push that into database.
    So Can any body please help me in this. My constraint is that I have to insert the document as un-structured way.
    You help would be appriciated.
    Vish
    Message was edited by:
    user567405
    Message was edited by:
    user567405
    Message was edited by:
    user567405
    Message was edited by:
    user567405
    Message was edited by:
    user567405

    , it is giving some error Hmmm, six attempts and you still didn't manage to tell us what the actuall error message and number was. Oracle has thousands of error messages. If you would like us to help you, make it easy for us to figure out what's going on. Don't make us guess.
    Regards, APC

  • Any setting example in congig.xml to create a NTRealm?

    Hi,
    Is there any setting example(in config.xml) for NTRealm since I am not able
    to create one from the admin console?
    Thanks!

    Hi,
    Is there any setting example(in config.xml) for NTRealm since I am not able
    to create one from the admin console?
    Thanks!

  • Inserting XML in SQLServer

    Hi
    I need to insert XML documents into SQLServer, preferably using bulk load XML. That uses ADO, and it is a piece of cake to insert XML from a VBScript or ASP or something else supported by microsoft. But my documents will come from a java application, do I need to convert the java object (string probably) to an ADO or what do I do? I've the feeling I'm not looking at this the right way, so any help will be greatly appreciated.
    Thank you, Helena
    ps. I have the microsoft SQL 2000 JDBC driver ds
    pps Any useful code example would just cause me to explode with happiness =) d.s

    ok two things, do you need to insert the whole document, like using full-text indexing? That is prob not a good way to go about it. If so you are getting an object from the Java app or is Java app producing a file?
    Once you answer those it will help.
    What I would do, is set up my database so it has an attribute for each of my xml elements, and then i would parse my xml document and insert each of the elements into the corresponding attribute in the database, that would be the easiest thing to do. Then if you want to recreate the xml file just read it out and create the file.
    This may be way off, but it is what i would do, rather than store the whole doc...
    good luck, hope i helped
    RDE

  • ORA-01000 during inserting xml files

    Hello,
    I'm using the following jdbc-code to insert xml files into oracle 10gRelease2:
    PreparedStatement stmt = null;
    Connection conn = getConnection();
    try
    stmt = conn.prepareStatement("insert into security values (?)");
    } catch (Exception e) {
    System.err.println(e);
    BufferedInputStream bufferedInputStream;
    for (int i = 1; i < 500; i++)
    String docName = "../../../data/output/security/security" + i+ ".xml";
    try
    FileInputStream fileInputStream = new FileInputStream(docName);
    bufferedInputStream = new BufferedInputStream(fileInputStream, 5000);
    XMLType doc = null;
    doc = XMLType.createXML(conn, bufferedInputStream);
    stmt.setObject(1, doc);
    stmt.executeUpdate();
    doc.close();
    fileInputStream.close();
    } catch (Exception e) {
    System.out.println(i);
    System.err.println(e);
    conn.commit();
    The code is working fine when I insert less than 340 files. But when I try to insert more than 340 files I'm getting the error:
    java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
    ORA-01000: maximum open cursors exceeded
    Where do I open so many cursors? During creating the XMLType?
    Thx,
    Fabian

    I can reproduce this. Looks like a problem with the XMLType.createXML() method. Will confirm and file a bug if necessary. In the mean time the following works and has the same effect
    package com.oracle.st.xmldb.pm.examples;
    import com.oracle.st.xmldb.pm.common.baseApp.BaseApplication;
    import java.io.ByteArrayInputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.Reader;
    import java.io.Writer;
    import java.sql.SQLException;
    import oracle.jdbc.OracleCallableStatement;
    import oracle.jdbc.OraclePreparedStatement;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.CLOB;
    import oracle.xdb.XMLType;
    public class BulkInsertXMLType extends BaseApplication
       public static String TABLE_NAME  = "Table";
       public static String SOURCE_FILE = "File";
       public static String ITERATIONS  = "Iterations";
       public void doSomething(String[] Args) throws Exception
          OracleCallableStatement  statement = null;
          String statementText;
          XMLType xml;
          CLOB    clob = CLOB.createTemporary( getConnection(), true, CLOB.DURATION_SESSION);
          // statementText = "insert into " + this.getSetting(this.TABLE_NAME) + " values(:1)";
          statementText = "insert into " + this.getSetting(this.TABLE_NAME) + " values(xmltype(:1))";
          System.out.println("GetXMLType.doSomething : Driver Type = " + this.getDriver() + ". Statement = " + statementText);
          statement = (OracleCallableStatement) getConnection().prepareCall(statementText);
          for (int i=0; i < Integer.parseInt(getSetting(this.ITERATIONS)); i++)
            try {
              InputStream is = new FileInputStream(getSetting(this.SOURCE_FILE));
              // xml = XMLType.createXML(this.getConnection(),is);            
              // statement.setObject(1,xml);
              InputStreamReader reader = new InputStreamReader( is );
              Writer writer = clob.setCharacterStream(0);
              char [] buffer = new char [ clob.getChunkSize() ];
              for( int charsRead = reader.read( buffer );
              charsRead > - 1;
              charsRead = reader.read( buffer ) )
                 writer.write( buffer, 0, charsRead );
              writer.close();
              reader.close();
              statement.setCLOB(1,clob);
              boolean result = statement.execute();
              is.close();
              clob.truncate(0);
            catch (SQLException sqle) {
                System.out.println("SQL Exception caught after " + i + "Iterations");
                System.out.println(sqle);
                throw sqle;
          CLOB.freeTemporary(clob);
          statement.close();
          getConnection().commit();
          getConnection().close();
      public static void main (String[] args)
        try
          BulkInsertXMLType example = new BulkInsertXMLType();
          example.initializeConnection();
          example.doSomething(args);
        catch (Exception e)
          e.printStackTrace();
    }

  • LPX-00004 - Problems while inserting xml files in a xmltype column

    I've faced two problems while trying to insert xml files into my table containing a xmltype column:
    create table xml_test (id number(20),content xmltype)
    I use following java code for writing xml docs into db:
         conn.setAutoCommit(false);
         OraclePreparedStatement stmt = (OraclePreparedStatement)
              conn.prepareStatement("INSERT INTO xml_test (id,content) VALUES(?,?)");
         File file = new File(file1);
         InputStream in1 = new FileInputStream(file1);
         Reader r1 = new BufferedReader(new InputStreamReader(in1, "UTF-8"));
         int len = 0;
         StringBuffer text = new StringBuffer();
         while ((len = r1.read()) != -1) {
              text.append((char) len);
         in1.close();
         r1.close();
         XMLType poXML1 = XMLType.createXML(conn, text.toString());
         for (int i = 1; i <= 1; i++) {
              stmt.setInt(1, i);
              stmt.setObject(2, poXML1);
              stmt.execute();
         conn.commit();
    1. problem: occures only if a xml schema has been assoicated to the specific xmltype column. it seems that the length of a specific xml tag in the document is limited. but why?
    java.sql.SQLException: ORA-22814: attribute or element value is larger than specified in type
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
         at test.insertXML(test.java:84)
         at test.main(test.java:261)
    hier the xml-schema of the xmltype column "content":
    <?xml version="1.0" encoding="UTF-8"?>
    <!--W3C Schema generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:element name="AUTOR-ID" type="xs:string"/>
         <xs:element name="BODY" type="xs:string"/>
         <xs:element name="CONTENT">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="METADATEN"/>
                        <xs:element ref="BODY"/>
                   </xs:sequence>
                   <xs:attribute name="content-id" type="xs:string" use="required"/>
              </xs:complexType>
         </xs:element>
         <xs:element name="DATUM" type="xs:string"/>
         <xs:element name="KEYWORD" type="xs:string"/>
         <xs:element name="METADATEN">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="DATUM"/>
                        <xs:element ref="TITEL" maxOccurs="unbounded"/>
                        <xs:element ref="KEYWORD" maxOccurs="unbounded"/>
                        <xs:element ref="AUTOR-ID"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="TITEL" type="xs:string"/>
    </xs:schema>
    2. problem: hier i have no idea what is happening ... please help
    java.sql.SQLException: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00004: internal error "MultiChar overflow"
    Error at line 61
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
         at test.insertXML(test.java:53)
         at test.main(test.java:259)

    It's hard for me to tell you more without seeing your instance data, but for problem #1, if you look at the underlying SQL types being generated by your schema, you will see that the default SQL mapping for a "string" in your schema is a VARCHAR2(4000) (and I believe this would be only 2000 for a varying width character set like UTF8).
    You can specify that you wish this column to be mapped as a CLOB in your schema if this is the problem. Also note that there is a 64K limit on the size of an individual node in XMLType.

  • Insert XML content  from BLS to oracle table

    Hi,
    Is there any way to send XML content from BLS to Oracle table. I tried with FixedQueryWithOuput. It works, but it has limitation, it cannot take more than 4000 character , even though the param is configured as clob in oracle database side?

    Sajjad
    This is not issue from xMII-side itself, instead this is an Oracle issue itself. This has some limitation in manipulating data in Database.
    Managing CLOBs and BLOBs in JDBC is not very simple when compared to managing small amount of data. The way the CLOB and the BLOB objects are created and managed is different than a VARCHAR(String) column. In fact, Oracle extension classes are provided to support these types objects in JDBC like oracle.sql.CLOB, oracle.sql.BLOB etc.
    The new enhancements in Oracle JDBC 10g promises to simplify the insertion and retrieval techniques for the CLOBs using the standard APIs. This document enumerates how easily the CLOB data can be handled in JDBC, by harnessing the new features of the Oracle JDBC 10g driver
    Anyway, to more get info on Oracle problems u may read  <a href="http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/handlingclobsinoraclejdbc10g.html">this</a>
    Regards
    Som

  • Attaching two XML docs together using XPath

    Hi,
    I have a conceptual question about whether something can be done in Oracle XML DB.
    I have two XML docs, doc1 and doc2. I want to attach doc2 to doc1 at some particular subelement of doc1's root element. I know the path to this subelement because I have an XPath which uniquely identifies that subelement. Assuming that these two docs are XMLTYPEs, is there a way to do this using XML DB functions, given only the XPath? Also, keep in mind that I don't know the structure of the documents at development time
    To better explain my question here is a stupid-simple example:
    doc1:
    <company>
    <department name="Sales"/>
    <department name="Marketing"/>
    </company>
    doc2:
    <employees>
    <employee name="Fred"/>
    <employee name="Jim"/>
    </employees>
    I want to attach doc2 into doc1 under doc1's <department name="Sales"/> element.
    I know that the XPath to this element is "/company/department[@name='Sales']"
    Is there any kind of Oracle magic that, given only doc1, doc2 and this XPath, would give me doc3:
    <company>
    <department name="Sales">
    <employees>
    <employee name="Fred"/>
    <employee name="Jim"/>
    </employees>
    </department>
    <department name="Marketing"/>
    </company>
    Although it seems kind of silly, whether or not this is possible will have to determine whether I use Oracle XML DB for my application. Also, in some situations the subelement I am attaching under may be nested 3, 4 or more elements below the root.
    Thanks in advance for any help,
    -Brad

    Yep ... exactly what I'm trying to do ... but it still don't work. This is what I get when I paste that into my SQL*Plus interface:
    SQL> set long 100000
    SQL> select updateXML(
    2 xmltype('
    3 <Document>
    4 <DocInfo>
    5 <EntityRef>EntityName</EntityRef>
    6 </DocInfo>
    7 <Body>
    8 <EntityRef>Entity2</EntityRef>
    9 </Body>
    10 </Document>'),
    11 '//EntityRef[text()="Entity2"]',
    12 XMLType('<NewRef>Something New</NewRef>')) from dual;
    UPDATEXML(XMLTYPE('<DOCUMENT><DOCINFO><ENTITYREF>ENTITYNAME</ENTITYREF></DOCINFO
    <Document>
    <DocInfo>
    <EntityRef>EntityName</EntityRef>
    </DocInfo>
    <Body>
    <EntityRef>Entity2</EntityRef>
    </Body>
    </Document>
    Is there a version of something or a pointer or a wrong package or something that I should be looking for? It's acting almost as though the functionality is stubbed out or not casting right or something.
    Here's an even odder deal:
    SQL> set long 100000
    SQL> select updateXML(
    2 xmltype('
    3 <Document>
    4 <DocInfo>
    5 <EntityRef>EntityName</EntityRef>
    6 </DocInfo>
    7 <Body>
    8 <EntityRef>Entity2</EntityRef>
    9 </Body>
    10 </D[i]Long postings are being truncated to ~1 kB at this time.

  • Error while inserting XML data

    Hi,
    When I try to insert xml data, it gives the following error.
    --CREATE TABLE XMLTABLE OF XMLType;
    INSERT INTO XMLTABLE VALUES(XMLTYPE(getCLOBDocument('example.xml')));
    ORA-00600: internal error code, arguments: [qmxiUnpPacked2], [121], [], [], [], [], [], []
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
    Any ideas?

    I've updated the FAQ with the answer to this one..
    XML DB FAQ

  • Data corruption when inserting xml to database

    Hi,
    I have discovered that some data get changed when I try to insert them into the database.
    It seems that at a certain point, there is a buffer somewhere that runs full, and then some data get missing, and get replaced by other (so that some data are duplicate, while some are missing).
    I get no error messages from the script indicating that anything is wrong.
    Anyone who have an idea of where changes need to be made to the script??
    thanks in advance,
    Reidun
    I use the following script:
    import oracle.xml.sql.dml.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.jdbc.*;
    import java.net.*;
    public class test_java
    public static void main(String args[])
    if (args.length != 5)
    System.out.println("Usage: test_java <xml_directory> <table_name> <username> <passwd> <database>");
    System.exit(-1);
    String dirName = args[0];          // path to xml file
    String tabName = args[1];          // table into which to insert
    String fileName = dirName + "/" + tabName + ".xml";     // file name containing the xml doc
    System.out.println("Read from " + fileName);
    System.out.println("Insert into table " + tabName);
    String s_username = args[2];
    String s_passwd = args[3];
    String s_db = args[4];
    String s_connect = "jdbc:oracle:oci8:" + s_username + "/" + s_passwd + "@" + s_db;
    System.out.println("Connect: " + s_connect);
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn =
    DriverManager.getConnection(s_connect);
    OracleXMLSave sav = new OracleXMLSave(conn, tabName);
    sav.setDateFormat("yyyy-MM-dd HH:mm:ss");
    sav.setIgnoreCase(true);
    sav.setRowTag(tabName);
    System.out.println("createURL...");
    URL url = sav.createURL(fileName);
    System.out.println("URL = " + url);
    int rowCount = sav.insertXML(url);
    sav.close();
    System.out.println(" successfully inserted "+rowCount+
              " rows into "+ tabName);
    conn.close();
    catch (Exception e) {
    System.out.println("Error: " + e.toString());
    System.out.println("Aborting XML import for " + tabName);     

    Try setting the batch size to 1 ( ie oracleXMLSave().setBatchSize(1);)
    The batch size defaults to 17 and sometimes this might cause similar behavior. It wonder if there is a bug already reported on this.
    Alex

  • Signing a XML Doc

    Hi All,
    Can any one give me sample code for signing a xml doc using oracle security developer tools.
    Thanks,
    Iceman

    Searching the forum or Java Security documentation would've resulted in many examples, but here is a self-contained one:
    XML dsig: Can I sign a SignatureProperty of the Signature?
    Arshad Noor
    StrongAuth, Inc.

Maybe you are looking for