如题
想在页面打开时显示一个图片
操作过程
mm.jsp<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<img src="lookphoto.do" />
</body>
</html>action 
public class lookphoto extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
    HttpSession session=request.getSession();
    try{
    response.setContentType("image/jpg");
    ServletOutputStream out = response.getOutputStream(); 
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();    
      String linkString="jdbc:sqlserver://172.16.16.155:1433; databaseName=dtxtest";
      Connection conn=DriverManager.getConnection(linkString,"dtx_1","dtx_1");
      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery("select bb from test_1 where id=1");
      rs.next();
     Blob blob=rs.getBlob(1);
 BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream());
      byte[] buffer = new byte[1024]; 
     int num = 0; 
     while ((num = in.read(buffer, 0, buffer.length)) != -1) { 
      out.write(buffer, 0, num);}  //这里出的错!!
    in.close();
    out.flush();
    out.close();
    }
    catch(Exception e)
    {
     e.printStackTrace();
    } return null;
}

解决方案 »

  1.   

    是数据库的并发问题可能是lz的补丁没打或的打的不对重新打一下,先打sp3试一试,不行就打sp4看看
      

  2.   

    我用的是server 2005,应该打什么补丁?有sp3?sp4?
      

  3.   

    1.打sql sp4 补丁
    2.使用sql 2005 jdbc驱动(sqljdbc.jar) 注意是只有1个jar文件
      

  4.   

    String linkString="jdbc:sqlserver://172.16.16.155:1433; databaseName=dtxtest"; 
    要用到1433 端口