sqlserver 2005数据库里面的varbinary(8000)字段里面我上传了小图片,怎么让其在前台和后台显示出来?

解决方案 »

  1.   

    读:
    <%
    String rcdId = "1";
    //String termId = Common.getString(request,"termId");
    String sql = "select photo from termPhotoIndex where  rcdId = "+rcdId+" order by dtime desc";
    Connection conn = DBConn.getConnection();
    java.sql.Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(sql); 
    //System.out.println(sql);
    while(rs.next()) {  
        InputStream in = rs.getBinaryStream("photo"); 
        ServletOutputStream op = response.getOutputStream(); 
        int len; 
        byte[] buf=new byte[1024]; 
        while((len= in.read(buf))!=-1) { 
         op.write(buf, 0, len); 
      
        } 
      op.close(); 
        in.close(); 
       } 
       
       rs.close(); 
       stmt.close(); 
       conn.close(); %> 
      

  2.   

    可能楼上的都没理解我的意思。
    我的意思是:前台开发语言室eclipse,后台是sqlserver 2005,我通过前台操作,上传了一些小图片到数据库中,怎么能在后台看到那些图片二不是二进制文件,前台用的表格表格控件。
      

  3.   


    楼主,你想select 语句显示图片??好像没有哪个数据库做到了噢。你要看到图片,只能通过程序取出来存成流或文件来看。