http://community.csdn.net/Expert/topic/2984/2984158.xml?temp=.7139093

解决方案 »

  1.   

    你可以用blob大对象来进行存储.
    java端可以这样处理:
    我这里是基于weblogic连接池的情况下:
    用Class.forName()方式会有点区别.大小差异不大.public java.io.ByteArrayOutputStream readFileFromDB(int index,String ifwhere){          InputStream is=null;
              int bytesread=0;
              byte []butter=new byte[8*1024];
              java.io.ByteArrayOutputStream bos=null;
              String sql="";
              java.sql.Blob blob = null;
              sql=sqlblob[index]+ifwhere;
              System.out.println(sql);          System.out.println(sql);
              try{            //Initialization ByteArrayOutputStream
                  bos = new java.io.ByteArrayOutputStream();              //Get Connection
                  con = new DBconn().getConnection();              pst = con.prepareStatement(sql);
                  rs = pst.executeQuery();
                  int size = 0;
                  while (rs.next()) {                //Get Blob
                    blob = rs.getBlob(1);
                    if(blob.length()!=0)
                      is = blob.getBinaryStream();
                  }              while(((bytesread=is.read())!=-1)){
                    bos.write(bytesread);
                  }          }catch (Exception e) {
                  System.out.println(e.toString());
              }finally {
                  try {
                      if (rs != null)
                          rs.close();
                      if (pst != null)
                          pst.close();
                      if (con != null)
                          con.close();              }
                  catch (Exception e) {
                      System.out.println("数据库连接错误:"+e.toString());
                  }
              }
          return bos;
          }