查查jdk,应该有createImage(byte[])

解决方案 »

  1.   

    Connection conn = null;
     Statement stmt=null;
     ResultSet set=null;
         try{
    String cust_id=request.getParameter("CUST_ID2");
    String med_num=request.getParameter("MED_NUM2");
    String sql="SELECT MED FROM CUST_MED WHERE CUST_ID ='"+cust_id+"';
    conn = OurConn.getConnection();
            stmt = conn.createStatement();  
    set = stmt.executeQuery(sql);
    if(set.next()){
    InputStream in = set.getBinaryStream("MED"); 
    response.reset(); 
    response.setContentType("image/jpeg");
    byte[] b = new byte[1024]; 
    int a=0;
    int len;
    while((len=in.read(b))!=-1){
    response.getOutputStream().write(b); 
    a=1;
    }
    in.close(); 
    if(a==0)
                { }
    }
     }catch(Exception e){

     }finally{
    try{
    if(set!=null)
    set.close();
    }catch(java.sql.SQLException se){
    }
    try{
    if(stmt!=null)
    stmt.close();
    }catch(java.sql.SQLException se){
    }
        try{
        if(conn != null )
    conn.close();
        }catch(java.sql.SQLException se){
        } 
    }