当前位置: 代码迷 >> Java Web开发 >> 关于显示数据库图片的有关问题
  详细解决方案

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

热度:216   发布时间:2016-04-17 13:25:03.0
关于显示数据库图片的问题
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

------解决方案--------------------
lz的方法不好,一般存放图片路径,不妨内容,不同数据库的binary格式不同,不好移植
  相关解决方案