不要用thin
用oci8
jdbc:oracle:oci8:@db

解决方案 »

  1.   

    用longraw型的吧,没问题。
    我也遇到过这个问题,也是存了超过一定大小就存不进去了。
      

  2.   

    没碰到过这问题啊,blob最大有4G呢。我存过20兆的文件,没有问题,速度稍慢点
      

  3.   

    我用以下的方法就没有问题这是问什么啊?
       conn.setAutoCommit(false);
       sql="insert into lobdemo (key,blob_col) values (" + idkey + ",'0')";
       Statement stmt1=conn.createStatement();
       stmt1.executeUpdate(sql);
       stmt1.execute("commit");
       sql = "select blob_col from lobdemo where key=" + idkey + " for update";
       res = stmt1.executeQuery(sql);
       res.next();
       oracle.jdbc2.Blob blob=((oracle.jdbc.driver.OracleResultSet) res).getBLOB(1);
       FileInputStream fis = new FileInputStream(imgFile);
       OutputStream fos = ((oracle.sql.BLOB)blob).getBinaryOutputStream();
       byte[] buffer1 = new byte[1024];
       int len;
       while ( (len = fis.read(buffer1)) != -1)  fos.write(buffer1, 0, len);
      

  4.   

    对于流的操作,最好使用Buffer
    Connection conn = null;
        ResultSet rs = null;
        Statement stmt = null;
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        oracle.sql.BLOB content = null;
        try {
          conn = getConnection();
          conn.setAutoCommit(false);
          stmt = conn.createStatement();
          stmt.executeUpdate(sql);
          rs = stmt.executeQuery(sqlBlob);
          while (rs.next()) {
            content = (oracle.sql.BLOB)rs.getBlob("content");
          }
          bos = new BufferedOutputStream(content.getBinaryOutputStream());
          bis = new BufferedInputStream(sis);
          byte[] buffer = new byte[ content.getBufferSize() ];
          int bytesRead = 0;
          int hasRead = 0;
          while( ( bytesRead = bis.read( buffer ) ) != -1 ) {
           hasRead += bytesRead;
           if (hasRead > fileSize) {
           bytesRead = bytesRead - (hasRead - fileSize);
           }
           bos.write( buffer, 0, bytesRead );
          
          }
          bos.flush();
          bos.close();
          bis.close();
          conn.commit();
          conn.setAutoCommit(true);
        } catch(Exception e1) {
          System.out.println("e1: " + e1.getMessage());
          try {
         conn.rollback();
            conn.setAutoCommit(true);
            bos.flush();
            bos.close();
            bis.close();
          } catch (Exception e2) {
           System.out.println("e2: " + e2.getMessage());
          }
        } finally {
          this.disconnect(rs, stmt, conn);
        }