ResultSet rs     
InputStream fileStream = rs.getBinaryStream("BMP");
byte[] buf = InputStreamTobytes(fileStream);

解决方案 »

  1.   

    InputStreamTobytes这个函数是用来做什么的?我出现如下的错误    [javac] Since fork is true, ignoring compiler setting.
        [javac] Compiling 1 source file
        [javac] Since fork is true, ignoring compiler setting.
        [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\jw\test\testlong_jsp.java:61: cannot resolve symbol
        [javac] symbol  : method InputStreamTobytes (java.io.InputStream)
        [javac] location: class org.apache.jsp.testlong_jsp
        [javac]      byte[] buf = InputStreamTobytes(gif_data);
        [javac]                          ^
        [javac] 1 error
      

  2.   

    <%@ page import="java.sql.*"%>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="com.jspsmart.upload.*" %>
    <%@ page import="DBstep.iDBManager2000.*"%>
    <%
      //打开数据库
      ResultSet result=null;
      String Sql=null;
      PreparedStatement prestmt=null; 
      DBstep.iDBManager2000 DbaObj=new DBstep.iDBManager2000();
      DbaObj.OpenConnection();
     //取得数据库中的数据
     Sql="select  *  from  list order by date desc";
     result=DbaObj.ExecuteQuery(Sql);
     result.next();
     //将数据库中的数据读到流中
      InputStream in =result.getBinaryStream("body"); 
     //设置输出的格式 
      response.reset(); 
      response.setContentType("image/jpeg");
     //循环去出流中的数据 
      byte[] b = new byte[1024]; 
      int len; 
      while((len=in.read(b)) >0) 
      response.getOutputStream().write(b,0,len); 
      in.close(); 
    %>
      

  3.   

    sorry,InputStreamTobytes是我自己写的一个方法
      public static byte[] InputStreamTobytes(InputStream ao_in) throws IOException{
        ByteArrayOutputStream lo_Out = new ByteArrayOutputStream();
        int li_data = ao_in.read();
        while(li_data != -1){
          lo_Out.write(li_data);
          li_data = ao_in.read();
        }
        return lo_Out.toByteArray();
      }