java.io.StreamCorruptedException: invalid stream header: 00013174
java.io.StreamCorruptedException: invalid stream header: 00013174
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
at testSendCmsJson.TestDatapool.main(TestDatapool.java:54)
ResultSet rs = null;
try {
//加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="";
//通过DriverManager获取连接
Connection conn=DriverManager.getConnection(url,"","2020");
conn.setAutoCommit(true);
//准备操作数据库
//Statement:用于执行静态SQL语句并返回它所生产结果的对象
String where =" where id=115982 and FEP=23750";
PreparedStatement stmt=conn.prepareStatement("select blobData from DATA "+where);
rs = stmt.executeQuery();
while(rs.next()){
InputStream in = rs.getBinaryStream(1);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte[4132];
int count = -1;
while((count = in.read(data,0,1024)) != -1)
outStream.write(data, 0, count);
// Blob b = rs.getBlob(1);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
bais.toString().getBytes();
// Object obj = ObjectUtil.byteArrayToObject(data);
ObjectInputStream oInputStream=new ObjectInputStream(bais);
Object obj=oInputStream.readObject();
System.out.println(obj);
}
在轉換成對象,
byte[] data = new byte[4132]; 不夠大 ,不夠裝下對象數據,所以報錯了。