你可以在JAVA中使用DB中的类似于appendblob,getblob一类的函数来试一试。

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/83/83096.shtm
      

  2.   

    你用的是什么数据库,我用oracle没出国什么问题
      

  3.   

    请问skyyoung(路人甲),如果blob或clob的数据过大,setBinaryStream(1,fis,file.length());中file.length()是int型的,长度不够怎么办?
      

  4.   

    你写的没错了,在
          OutputStream os = b.getBinaryOutputStream(); 
          os.write(byteArr); 
          os.close(); 
    之前当然为null了
    如果是其它原因,你可以试试在插入时,给Blob字段插入一个小于4k的任意值,或是empty_blob()了
        
      

  5.   

    大家看一看这段代码
    public void writeBlob(String picID, String fileName) {
      File file = new File(fileName);
      FileInputStream fis = null;
      PreparedStatement ps = null;  try {
        fis = new FileInputStream(file);
        ps = connection.prepareStatement("insert into pictest values (?,?)");
        ps.setString(1, picID);
        ps.setBinaryStream(2, fis, (int)file.length());
        ps.execute();
      } catch (Exception e) {
        System.out.println("Exception at PictureDb.writeBlob: " + e);
      } finally {
        try {
          ps.close();
          fis.close();
          } catch (Exception e) {
          }
      }
    }出现下面的异常
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
      

  6.   

    import oracle.sql.*;
    BLOB b = (BLOB) rs.getBlob("pic"); 
    ://此处取得的BLOB b总是null 
          OutputStream os = b.getBinaryOutputStream(); 
          os.write(byteArr); 
          os.close(); 
        
      

  7.   

    你的pic字段值为null
    估计你是用Insert into tablename(....., pic) values(....., null);
    这种方式插入的记录,换成
    Insert into tablename(....., pic) values(....., empty_blob());
    再次更新就不会有如下错误了!