java操作Orcale数据库blob字段,或者是clob字段,更新的对象都不能超过3K,其他字段都能够正常操作,小于3k的blob字段也能正常更新,blob字段更新对象如果超过3k,原有内容将青空,而且在运行的时候不抛出任何异常,请教大家这是为什么呢??
搞了一天了,也没弄出来,求求大家了~~~~~

解决方案 »

  1.   

    String statement = " update BTEST set blob=? where id='2'";
     File f = new File("D:/ldap.java");
    FileInputStream fis = new FileInputStream(f);
    pstmt = con.prepareStatement(statement);
    pstmt.setBinaryStream(1,fis,(int)f.length());
    pstmt.execute();
    pstmt.close();
    con.close();
    fis.close();
    我的测试代码如上,这个文件(D:/ldap.java)5k,就不能正常更新。
      

  2.   

    用preparedStatement更新最多只能更新3000,这是规定的,用Statement试试
      

  3.   

    不知道怎么回事 power1128(苏-37) :
    这个3000是哪里来的?Statement没有这个方法。
      

  4.   

    blob的内容是动态的啊,怎么用Statement呢,有没有相应的示例代码呢,谢谢了
      

  5.   

    你要更新blog字段,必然要用preparedStatement!
    而且,autoCommit要关掉!
    connection.setAutoCommit(false);
                    String sql2="select contents from myda where id="+id+" for update";
                    stmt=connection.prepareStatement(sql2);
                    ResultSet rs=stmt.executeQuery();
                    if(rs.next()){
                        BLOB blob=(BLOB)rs.getBlob(1);
                        OutputStream outStream=blob.getBinaryOutputStream();
                        outStream.write(data);
                        outStream.flush();
                        outStream.close();
                    }
                    connection.commit();