关于显示数据库图片的问题
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
搜索更多相关主题的帖子:
数据库
----------------解决方案--------------------------------------------------------
大侠在哪里?
----------------解决方案--------------------------------------------------------
byte b[] = new byte[0x7a120]是不是这里错了 数组定义byte[] b?不是很理解你要做什么
----------------解决方案--------------------------------------------------------
把数据库中的二进制图片显示出来
----------------解决方案--------------------------------------------------------