简体   繁体   English

将Clob读入xml解析器的最安全方法

[英]safest way to read clob into xml parser

I'm getting an input stream from a Clob in oracle 11 (using the the oracle 11 jdbc driver), and passing the input stream to an xml parser in Java: 我从oracle 11中的Clob获取输入流(使用oracle 11 jdbc驱动程序),并将输入流传递给Java中的xml解析器:

java.sql.Clob clob = resultSet.getClob("myClob");
InputStream is = clob.getAsciiStream();
MyDom dom = MyDomParser.parse(is);

Wondering if using a CharacterStream would be safer? 想知道使用CharacterStream是否更安全? eg instead: 例如:

Reader r = clob.getCharacterStream();
MyDom dom = MyDomParser.parse(r);

My thinking is that getCharacterStream() might be doing some encoding that helps guarantee nice UTF-8 is returned. 我的想法是getCharacterStream()可能正在做一些编码,以确保返回好的UTF-8。 Not sure if there is any real difference between the two ways shown here of reading the clob. 不知道这里显示的读取Clob的两种方法之间是否存在真正的区别。

Not much difference, getCharacterStream is better for unicode data. 没有太大的区别,getCharacterStream对于Unicode数据更好。 Check the link http://community.actian.com/wiki/Manipulating_SQL_CLOB_data_with_JDBC 检查链接http://community.actian.com/wiki/Manipulating_SQL_CLOB_data_with_JDBC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM