Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Posts
    1

    Exclamation Unanswered: Inserting into XmlType large docs

    I am trying to insert a large XML doc into an XMLType column in Oracle 9i using jdbc. I am having a problem because the size of the doc is over 4k. I have not been sucessful in inserting. However, I feel a good strategy is to treat the xmltype insert as a CLOB insert. I'm not sure if it will work???? Any suggestions would be greatly appreciated!

    here is the code I have working with. The table is called xmltest and has 2 columns id number and peaklist xmltype.

    try
    {
    con.setAutoCommit(false);

    String sql1="insert into XMLTest (id,peaklist) VALUES(?,sys.xmlType.createXML(empty_Clob()))";

    PreparedStatementps=con.prepareStatement(sql1);
    ps.setInt(1,1);

    ps = con.prepareStatement("SELECT * from xmltest where id = 1 FOR UPDATE");
    rs=ps.executeQuery();
    if(rs.next())
    {
    oracle.sql.CLOB myCLOB = (oracle.sql.CLOB)rs.getObject("peaklist");

    java.io.Writer CLOBout = myCLOB.getCharacterOutputStream();
    String XMLDoc = SparkyToXml.SparkyToXml(peakListLoc);
    out.println("XMLDOC " + XMLDoc);
    CLOBout.write(XMLDoc);
    }

    rs.close();
    ps.close();
    con.commit();
    con.setAutoCommit(true);
    }catch(Exception e) { out.println("error in 1 " + e);}



    I am recieving a nullpointer exeception. Help!!!

  2. #2
    Join Date
    Jan 2003
    Posts
    1

    Re: Inserting into XmlType large docs

    Did you find any solutions for this ? I am running into the same problem


    Originally posted by mcbaran
    I am trying to insert a large XML doc into an XMLType column in Oracle 9i using jdbc. I am having a problem because the size of the doc is over 4k. I have not been sucessful in inserting. However, I feel a good strategy is to treat the xmltype insert as a CLOB insert. I'm not sure if it will work???? Any suggestions would be greatly appreciated!

    here is the code I have working with. The table is called xmltest and has 2 columns id number and peaklist xmltype.

    try
    {
    con.setAutoCommit(false);

    String sql1="insert into XMLTest (id,peaklist) VALUES(?,sys.xmlType.createXML(empty_Clob()))";

    PreparedStatementps=con.prepareStatement(sql1);
    ps.setInt(1,1);

    ps = con.prepareStatement("SELECT * from xmltest where id = 1 FOR UPDATE");
    rs=ps.executeQuery();
    if(rs.next())
    {
    oracle.sql.CLOB myCLOB = (oracle.sql.CLOB)rs.getObject("peaklist");

    java.io.Writer CLOBout = myCLOB.getCharacterOutputStream();
    String XMLDoc = SparkyToXml.SparkyToXml(peakListLoc);
    out.println("XMLDOC " + XMLDoc);
    CLOBout.write(XMLDoc);
    }

    rs.close();
    ps.close();
    con.commit();
    con.setAutoCommit(true);
    }catch(Exception e) { out.println("error in 1 " + e);}



    I am recieving a nullpointer exeception. Help!!!

  3. #3
    Join Date
    Jan 2003
    Posts
    1

    alternative solutions

    try to use temporary table for uploading clob data:

    create table clob_temp (
    id varchar2(64),
    content clob)

    when data are in databes use trigger or sql statement like this

    insert into XMLTest values
    (
    id,
    xmltype((select content from clob_temp where id='id')),
    )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •