注册 登录
编程论坛 J2EE论坛

关于显示数据库图片的问题

wangliwei 发布于 2007-07-24 13:06, 499 次点击
try{

String wpId=request.getParameter("wpId");
if(wpId!=null){
ResultSet rs=cn.executeQuery("select wp_yangpin1 from wp_tbl where wp_id='"+wpId+"'");
//Blob image=(Blob)wupin.getWpYangpin1();
while(rs.next()){
ServletOutputStream sout = response.getOutputStream();
InputStream in = rs.getBinaryStream("wp_yangpin1");
byte b[] = new byte[0x7a120];
for(int i = in.read(b); i != -1;)
{
sout.write(b);
//将缓冲区的输入输出到页面
in.read(b);
}
sout.flush();
//输入完毕,清除缓冲
sout.close();

}

}
}catch(Exception e){
System.out.println(e);
}
抛出异常:ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error
3 回复
#2
wangliwei2007-07-25 09:39
大侠在哪里?
#3
a2762024602007-07-25 10:02
byte b[] = new byte[0x7a120]是不是这里错了 数组定义byte[] b?不是很理解你要做什么
#4
wangliwei2007-07-26 08:31

把数据库中的二进制图片显示出来

1