探讨一下xmltype的存储问题!

netneighbor 2005-08-24 02:36:45
在表中建立一xmltype字段,在xmltype选项中选择不基于方案的时候不能存入比较大的xml数据,只能存储较小的数据,据说是4k以下的,存较大的需要建临时的clob类型,倒一下;
在选择基于xml方案时,选择XDB方案,存储为clob类型,不知该怎样存储数据(写pL语句)。
如果存入大的数据时,也需要用clob倒那么如何倒呢?
...全文
146 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjb030320134 2005-08-31
  • 打赏
  • 举报
回复
String insertgml = "INSERT INTO system.gmltable VALUES (?,?,?,?,?,?," +
"XMLType(?))";
pstmt = conn.prepareStatement(insertgml);


clob = getCLOB(gml);

pstmt.setFloat(6, ymax);
pstmt.setObject(7, clob);
zjb030320134 2005-08-31
  • 打赏
  • 举报
回复

//用于处理大于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;
}
stonetear 2005-08-26
  • 打赏
  • 举报
回复
等待
stonetear 2005-08-25
  • 打赏
  • 举报
回复
没有人使用XMLTYPE类型吗?请高手门给指点一下.

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧