我的代码,上传30M以内没问题。
 String strSql ="update tn set pm_name='" + fileName +"' , pm_direc= empty_blob() where pm_id=" +id ;
 stmt.execute(strSql);
String sql ="select pm_direc from tn where pm_id="+id+" for update ";
ResultSet rs=stmt.executeQuery(sql);
if (rs !=null&& rs.next()){
                             
oracle.sql.BLOB blob = ((oracle.jdbc.OracleResultSet)rs).getBLOB("pm_direc");
             
 OutputStream outStream = blob.getBinaryOutputStream();   byte[] bytes = new byte[fileSize];
  inStream.read(bytes);
  outStream.write(bytes);
  outStream.flush();
   stmt.execute("commit");如果上传的还要大,可以把文件分解,在循环中读字节流,我是那样做的。40M的也传过,不过速度比较慢,要3分40秒。

解决方案 »

  1.   

    看看我的帖子,用我编的小程序试试
    http://expert.csdn.net/Expert/topic/1641/1641193.xml?temp=.784588
      

  2.   

    /*
    InputStream is=new FileInputStream(path2);//创建输入流,将外部文件输入到InputStream 中。
       
        byte[] blobByte=new byte[is.available()];
       is.read(blobByte);
       is.close();
        PreparedStatement pstmt=conn.prepareStatement("INSERT INTO test  VALUES (?)");
       
        pstmt.setBinaryStream(1,(new ByteArrayInputStream(blobByte)), blobByte.length);

        pstmt.executeUpdate();//将文件流插入到数据库中。
    pstmt.close();
    */
      

  3.   

    数据库用的什么字段,应该是blob吧
      

  4.   

    字段大小问题,我以前也遇到过,改下DB的字段大小就OK
      

  5.   

    我使用的是blob怎么可以改字段大小呢?
      

  6.   

    超过5K后就有问题可能是缓存机制的问题不要想太多了,像chili1979(中国龙)那样,获得 blob 对象句柄来传就OK了。