有问题吧?len都没有初始化:
int len;
{
outs.write( buf , 0 , len );
}

解决方案 »

  1.   

    不好意思,int len;下有个while
    BLOB b = ( BLOB )dr.getItem( 0 );
    OutputStream outs = b.getBinaryOutputStream();
    ByteArrayInputStream bais = new ByteArrayInputStream( com.system.util.util.BASE64Decoder( dm.getParams().get( paramName ).getValue() ) );
    byte[] buf = new byte[ b.getChunkSize() ];
    int len;
    while( ( len = bais.read( buf ) ) != -1 )
    {
    outs.write( buf , 0 , len );
    }
    outs.flush();
    outs.close();
    bais.close();
      

  2.   

    我用过Clob大字段,不过也只是读里面的数据,没写过
      

  3.   

    我在写入BLOB字段是也遇到了同样的问题,更主要的是,在存入的数据大于2K时,无法正常读出
      

  4.   

    替换CLOB对象(将原CLOB对象清除,换成一个全新的CLOB对象),详细信息请参考:http://www.s8s8.net/ipb/lofiversion/index.php/t20319.html
      

  5.   

    import oracle.sql.*;
    import java.sql.*;
    import java.io.*;public class WriteBlob {  public static void main(String[] args) {    try {
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection conn = DriverManager.getConnection(
              "jdbc:oracle:thin:@192.168.0.204:1521:main", "lct", "lct");
          conn.setAutoCommit(false);
          BLOB blob = null;
          //清空
          PreparedStatement pstmt = conn.prepareStatement(
              "update javatest set content=empty_blob() where name=?");
          pstmt.setString(1, "liuchuntao");
          pstmt.executeUpdate();      pstmt = conn.prepareStatement(
              "select content from javatest where name= ? for update");
          pstmt.setString(1, "liuchuntao");
          ResultSet rset = pstmt.executeQuery();
          if (rset.next()) {
            blob = (BLOB) rset.getBlob(1);      }
          String fileName = "e:\\pic\\1.jpg";
          File f = new File(fileName);
          FileInputStream fin = new FileInputStream(f);
          System.out.println("file size = " + fin.available());      pstmt = conn.prepareStatement(
              "update javatest set content=? where name=?");      OutputStream out = blob.getBinaryOutputStream();      int count = -1, total = 0;
          byte[] data = new byte[ (int) fin.available()];
          fin.read(data);
          out.write(data);
         
          fin.close();
          out.close();      pstmt.setBlob(1, blob);
          pstmt.setString(2, "fankai");      pstmt.executeUpdate();
          pstmt.close();      conn.commit();
          rset.close();
          conn.close();
        }
        catch (SQLException e) {
          System.err.println(e.getMessage());
          System.out.println(e.getErrorCode());
          e.printStackTrace();
        }
        catch (IOException e) {
          System.err.println(e.getMessage());
        }
      }}