jsp中的oracle数据库问题

boy002 2003-09-28 11:06:03
如何用jsp查看oracle中表的blob,clob的数据,我用一般的方法返回的是空值,但在数据库中,却明明有值啊,请各位高手帮忙,还有如何设置jsp使其不自动commit,
谢谢!
...全文
30 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Geranium 2003-09-28
  • 打赏
  • 举报
回复
BLOB blob = null;
String strLength="";
while (rset.next()) {
blob = ((OracleResultSet) rset).getBLOB(1);
strLength=blob.length());
}
再弄个file文件存放它,这个就需要知道你的是什么类型的了,最后再显示文件。

File binaryFile = new File("c:\\xxxxx.xxx");
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = blob.getBinaryOutputStream();
int chunk = blob.getChunkSize();
byte[] buffer = new byte[chunk];
int length = -1;
while ((length = instream.read(buffer)) != -1)
outstream.write(buffer, 0, length);
instream.close();
outstream.close();
-->

如何直接在页面上显示,而不用创建一个文件存放它,这个问题我不会,期待各位兄弟谈谈思路~
shajia981112 2003-09-28
  • 打赏
  • 举报
回复
CLOB clob = ((OracleResultSet)rs).getCLOB("clobfieldname");
String content="";
if(clob!=null){
Reader is=clob.getCharacterStream();
BufferedReader br=new BufferedReader(is);
String s=br.readLine();
while(s!=null){
content+=s+",";
s=br.readLine();
}
content为你的clob内容
breeze517 2003-09-28
  • 打赏
  • 举报
回复
用getBlob(),getClob()都不行吗?
Geranium 2003-09-28
  • 打赏
  • 举报
回复
conn.setAutoCommit(false);

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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