利用ResultSet的方法
public InputStream getBinaryStream(String columnName)
获得InputStream
再通过字节数组
byte[] byteArray = new byte[8092]
一部分一部分写入FileOutputStream中

解决方案 »

  1.   

    必须要存储为byte[],应该如何做呢?
      

  2.   

    byte[] byteArray = new byte[8092];
    int len;
    InputStream is = rs.getBinaryStream("File_Bit");
    FileOutputStream f = new FileOutputStream("imagename.jpg");
    len = is.read(byteArray);
    while (len != -1)
    {
        f.write(byteArray, 0, len);
        len = is.read(byteArray);
    }
    f.close();
      

  3.   

    rubyz(左思右想) 的方法能生成文件,但是文件被损坏,不能浏览,这是为什么???
      

  4.   

    你好,毛毛熊,看你的那段代码,其中的数据库是sql server数据库,
      能告诉下是怎么调用上的吗?其中的数据源是怎么配置的以及在java中该选用什么驱动程序???
      

  5.   

    在ODBC的USER DSN中建立一个test数据源,然后就是下面的代码就关联上了SQL Server数据库了:
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          String s = "jdbc:odbc:test";
          Connection con = DriverManager.getConnection(s,"sa","88888");
          Statement stmt = con.createStatement();
          ResultSet rs = stmt.executeQuery(sql);