BLOB blob = null;
有错,,应是
Blob blob=rset.getBlob(1);
然后,
使用,,byte b[]=blob.getBytes(0,1024);自己设,下边有文档
getBytes(long pos, int length) 
          Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.

解决方案 »

  1.   

    byte b[]=blob.getBytes(0,1024);报错!
     DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        Connection conn = DriverManager.getConnection(
            "jdbc:oracle:thin:@localhost:1521:temp", "test", "123456");
        conn.setAutoCommit(false);
        PreparedStatement pstmt = conn.prepareStatement(
            "select content from javatest where name= ? for update");
        pstmt.setString(1, "fankai");
        pstmt.executeUpdate();
        ResultSet rset = pstmt.executeQuery();
        if (rset.next()) {
          Blob blob = rset.getBlob(1);
        }
        //OutputStream o = blob.getBinaryOutputStream();
        //InputStream in = blob.getBinaryStream();
        byte b[]=blob.getBytes(0,1024);********报错
        
        return b;
      

  2.   

    你的类我查过了,没有BLOB类只有java.sql.Blob
    byte[] bytes ;
        driverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        Connection conn = DriverManager.getConnection(
            "jdbc:oracle:thin:@localhost:1521:temp", "test", "123456");
        conn.setAutoCommit(false);
        java.sql.Blob blob = null;    PreparedStatement pstmt = conn.prepareStatement(
            "select content from javatest where name= ? for update");
        pstmt.setString(1, "fankai");
        pstmt.executeUpdate();
        ResultSet rset = pstmt.executeQuery();
        if (rset.next()) {
          blob = rset.getBlob(1);
          bytes =blob.getBytes(0,1024);    }
    这个我没有测,你试试吧
      

  3.   

    http://community.csdn.net/Expert/topic/4053/4053138.xml?temp=.8920709
    我的问题,你也看看吧
      

  4.   

    java.sql.SQLException: 调用中的无效参数: getBytes() at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.sql.BLOB.getBytes(BLOB.java:188) at test.WriteBlob.main(WriteBlob.java:112)Exception in thread "main" 
    就是这这一行:bytes =blob.getBytes(0,1024);**************
      

  5.   

    (oracle.sql.BLOB)blob = (oracle.sql.BLOB)rset.getBlob(1);
    b=blob.getBytes(1,blob.getLength());