Oracle LONG and LONG RAW Causing “Stream has already been closed” Exception
这应该算是Oracle的bug,为了弥补这个问题,Oracle给我们的建议是:在结果集处理时,要先把LONG字段读取掉,再去读其他字段。
CREATE TABLE t_long_raw_and_blob ( id NUMBER(7), blob1 BLOB, longx LONG RAW, blob2 BLOB, CONSTRAINT pk_t_long_raw_and_blob PRIMARY KEY (id) );
try (PreparedStatement s = con.prepareStatement( "SELECT * FROM t_long_raw_and_blob"); ResultSet rs = s.executeQuery()) { while (rs.next()) { byte[] longx = rs.getBytes(3); System.out.println(); System.out.println("ID = " + rs.getInt(1)); System.out.println("BLOB1 = " + rs.getBytes(2)); System.out.println("LONGX = " + longx); System.out.