关于从oracle中读取blob字段的问题

www_sql 2005-11-05 04:03:44
在bean里写一个从oracle里读取blob的方法,返回一个数据流,为什么再jsp中调用该方法不能获得该数据流?而在jsp页面中直接写确可以呀
...全文
193 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
www_sql 2005-11-15
  • 打赏
  • 举报
回复
是否还有别的解决方法
meconsea 2005-11-06
  • 打赏
  • 举报
回复
把文件生成到服务器上,在JSP中加上连接就OK
zyhowe 2005-11-05
  • 打赏
  • 举报
回复
前面加上格式输出..................
InputStream reader = blob.getBinaryStream();
byte[] buffer = new byte[1000];
int nbytes = 0;
while ((nbytes = reader.read(buffer)) != -1)
out.println(buffer);
www_sql 2005-11-05
  • 打赏
  • 举报
回复
谢谢楼上,如果是图片或影音文件应该返回什么?字节数组吗
zyhowe 2005-11-05
  • 打赏
  • 举报
回复
public static String parse(Blob blob) {
String content = "";
try {
InputStream reader = blob.getBinaryStream();
byte[] buffer = new byte[1000];
int nbytes = 0;
while ((nbytes = reader.read(buffer)) != -1)
content += new String(buffer, 0, nbytes);
reader.close();
} catch (Exception e) {
}
return content;
}
public static String parse(Clob clob) {
String content = "";
try {
Reader reader = clob.getCharacterStream();
char[] buffer = new char[1000];
int nbytes = 0;
while ((nbytes = reader.read(buffer)) != -1)
content += new String(buffer, 0, nbytes);
reader.close();
} catch (Exception e) {
}
return content);
}

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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