在表中建立一xmltype字段,在xmltype选项中选择不基于方案的时候不能存入比较大的xml数据,只能存储较小的数据,据说是4k以下的,存较大的需要建临时的clob类型,倒一下;
在选择基于xml方案时,选择XDB方案,存储为clob类型,不知该怎样存储数据(写pL语句)。
如果存入大的数据时,也需要用clob倒那么如何倒呢?

解决方案 »

  1.   

    没有人使用XMLTYPE类型吗?请高手门给指点一下.
      

  2.   


    //用于处理大于4k字节的xml
      private CLOB getCLOB(Document xmlData) throws SQLException {
        CLOB tempClob = null;
        try {
          // If the temporary CLOB has not yet been created, create one      tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);      // Open the temporary CLOB in readwrite mode, to enable writing
          tempClob.open(CLOB.MODE_READWRITE);
          // Get the output stream to write      Writer tempClobWriter = tempClob.getCharacterOutputStream();      System.out.println(tempClobWriter.getClass().toString());
          XMLWriter writer = new XMLWriter(tempClobWriter);      writer.write(xmlData);
          writer.flush();
          writer.close();      //  tempClobWriter.write(xmlData);      // Flush and close the stream
          //   tempClobWriter.flush();
          //   tempClobWriter.close();      // Close the temporary CLOB
          tempClob.close();
        }
        catch (SQLException sqlexp) {
          tempClob.freeTemporary();
          sqlexp.printStackTrace();
        }
        catch (Exception exp) {
          tempClob.freeTemporary();
          exp.printStackTrace();
        }
        return tempClob;
      }
      

  3.   

    String insertgml = "INSERT INTO system.gmltable  VALUES (?,?,?,?,?,?," +
            "XMLType(?))";
      pstmt = conn.prepareStatement(insertgml);     
          clob = getCLOB(gml);
     
          pstmt.setFloat(6, ymax);
          pstmt.setObject(7, clob);