社区
Web 开发
帖子详情
oracle中读取clob字段,有时报告out of memory错误
hhquan
2003-04-02 10:53:54
使用的数据库是oracle815,通过jdbc读取其中的clob字段,发现当clob中含有
的信息很大时,cpu的idle比例大幅下降,直到读取完毕后,cpu的idle才能恢
复。如果多个读取clob的程序并行发生,那么cpu的idle会降为0,并且前台java
程序会报告out of memory错误。
哪位大侠能够帮我解决啊?
...全文
144
4
打赏
收藏
oracle中读取clob字段,有时报告out of memory错误
使用的数据库是oracle815,通过jdbc读取其中的clob字段,发现当clob中含有 的信息很大时,cpu的idle比例大幅下降,直到读取完毕后,cpu的idle才能恢 复。如果多个读取clob的程序并行发生,那么cpu的idle会降为0,并且前台java 程序会报告out of memory错误。 哪位大侠能够帮我解决啊?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
hhquan
2003-04-03
打赏
举报
回复
后来我重新写了代码,将String变成了StringBuffer,问题得到了缓解,但是不知道,这种解决方法是否是最合适的?请大家赐教
ResultSet rs= null;
String szSQL="select clob_content from clob_t where seq=1";
rs =stmt.executeQuery(szSQL);
Clob cContent =null;
if(rs.next())
{
cContent= rs.getClob(1);
int tLen = (new Long(cContent.length())).intValue();
String content = cContent.getSubString(1, tLen);
StringBuffer str=new StringBuffer(tLen);
boolean goonReplace = true ;
int beginPos = 0 ;
int endPos = 0 ;
int idPos = 0 ;
while (goonReplace) {
beginPos = content.indexOf("\n",beginPos) ;
if( beginPos!=-1)
{ str=str.append(content.substring(0,beginPos)+"<br>");
content=content.substring(beginPos+1);
beginPos = 0 ;
}
else
{
str=str.append(content);
goonReplace = false ;
}
}
out.println(str.toString()); }
rs.close();
stmt.close();
conn.close();
hhquan
2003-04-02
打赏
举报
回复
ResultSet rs= null;
String szSQL="select clob_content from clob_t where seq=1";
rs =stmt.executeQuery(szSQL);
Clob cContent =null;
if(rs.next())
{
cContent= rs.getClob(1);
if (cContent != null)
{
Reader is = cContent.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
while (s != null)
{
sReturn += s + "<br>";
s = br.readLine();
}
is.close();
}
}
rs.close();
stmt.close();
conn.close();
out.println(sReturn);
qiuyang_wang
2003-04-02
打赏
举报
回复
建议读取时不要一次读取全部,可以调用dbms_lob包的有关功能实现分段读取。
sm8848
2003-04-02
打赏
举报
回复
是不是你的读取方法不对啊!
你前端是用什么方法进行读取的?
Web 开发
81,115
社区成员
341,731
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章