gpt4 book ai didi

java.io.StreamCorruptedException : invalid stream header: 4920616D

转载 作者:行者123 更新时间:2023-11-29 07:37:02 24 4
gpt4 key购买 nike

<分区>

您好,当我尝试读取 blob 时出现异常。我正在发布如何写入数据库并向数据库提出建议,这会导致太多问题..

ava.io.StreamCorruptedException: invalid stream header: 4920616D
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
at com.jiit.jfx.persistence.TypeHelper.readBlob(TypeHelper.java:137)
at com.jiit.jfx.persistence.TypeHelper.get(TypeHelper.java:84)
at com.jiit.jfx.persistence.dataaccess.OracleSQLQuery.get(OracleSQLQuery.java:116)
at com.jiit.jfx.persistence.dataaccess.OracleSQLQuery.doOperation(OracleSQLQuery.java:65)
at com.jiit.jfx.persistence.dataaccess.AbstractDAO.execute(AbstractDAO.java:181)
at com.jiit.jfx.persistence.dataaccess.AbstractDAO.executeSQL(AbstractDAO.java:208)
at

com.jiit.ngcs.mx.server.model.rail.ASMMessageStore.getASMMessageStore(ASMMessageStore.java:196)




enter code here

Reading BOLB :

public static Blob createBlob(Object serializable) throws PersistenceException{
try {
ByteArrayOutputStream bStream = new ByteArrayOutputStream();
ObjectOutputStream oStream = new ObjectOutputStream(bStream);
oStream.writeObject(serializable);
oStream.flush();
oStream.close();
return createBlob(bStream.toByteArray());
} catch (Exception e) {
throw new PersistenceException(e.getMessage());
}
}
in TypeHelper.java -- > createBlob


private static Object readBlob(int index, ResultSet rs) throws SQLException {
try {
InputStream is = rs.getBinaryStream(index);
if(is != null) {
ObjectInputStream os = new ObjectInputStream(is);
return os.readObject();
}
return null;
} catch (IOException e) {
e.printStackTrace();
throw new SQLException(e.getMessage());
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new SQLException(e.getMessage());
}

尝试了stackoverflow和其他博客中给出的所有案例。仍然不明白确切的问题。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com