我在Oracle 11G(11.1)中有一个表,其中包含一个包含XML文档的BLOB列。
XML文档已使用java程序写入表中,并已使用java.util.zip deflator进行序列化和压缩。
是否有一种简单的方法可以使用SQL或PLSQL提取此文档来反转用于创建BLOB列以获取原始XML文档的过程?
我从Web应用程序中识别出一段java,它读取的列类似于下面的代码,但出于支持目的,希望能够从后端访问列数据。
private IntegrationStagingDataBean fromObjectToBean(StagedMessage message) throws ServerException {
IntegrationStagingDataBean bean = new IntegrationStagingDataBean();
bean.setBusinessId(message.getBusinessId());
bean.setBusinessType(message.getBusinessType());
bean.setCreateTime(message.getCreateTime());
bean.setDeleted(message.hasBeenDeleted() ? "Y" : "N");
bean.setErrorMessage(message.getErrorMessage());
bean.setId(message.getId());
bean.setStoreId(message.getStoreId());
bean.setMessageDirection(message.getMessageDirection().getDbCode());
bean.setMessageFamily(message.getMessageFamily().getDbCode());
bean.setMessageType(message.getMessageType().getDbCode());
bean.setProcessed(message.hasBeenProcessed() ? "Y" : "N");
bean.setRetryCount(message.getRetryCount());
bean.setUpdateTime(message.getUpdateTime());
try {
bean.setSerializedDeo(ObjectUtils.toByteArray(new CompressedObject(message.getDeo())));
} catch (IOException ioex) {
throw new ServerException("Problem setting compressed serialized object", ioex);
}
return bean;
}
private StagedMessage fromBeanToObject(IntegrationStagingDataBean bean) throws ServerException {
DataExchangeObject deo = null;
Blob blob = (Blob) bean.getSerializedDeo();
try {
CompressedObject compressedObject = (CompressedObject) new
ObjectInputStream(blob.getBinaryStream()).readObject();
deo = (DataExchangeObject) compressedObject.recoverObject();
} catch (Exception e) {
throw new ServerException("Couldn't uncompress/deserialize DEO from BLOB", e);
}
+++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++
并发现以下附加功能分布在少数几个软件包中,表明它正在使用java.util.zip中的java函数deflater。*;
public CompressedObject(Object object) 抛出IOException { dataToSend = null; if(object!= null) dataToSend = ObjectUtils.toCompressedByteArray(object); }
public static final byte[] toCompressedByteArray(Object o)
throws IOException
{
return compressByteArray(toByteArray(o));
}
public static final byte[] compressByteArray(byte input[])
{
Deflater compressor = new Deflater(9);
compressor.setInput(input);
compressor.finish();
ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
byte buf[] = new byte[1024];
int count;
for(; !compressor.finished(); bos.write(buf, 0, count))
count = compressor.deflate(buf);
try
{
bos.close();
}
catch(IOException e) { }
return bos.toByteArray();
}
public static final byte[] decompressByteArray(byte arr[])
{
Inflater decompressor = new Inflater();
decompressor.setInput(arr);
ByteArrayOutputStream bos = new ByteArrayOutputStream(arr.length);
byte buf[] = new byte[1024];
while(!decompressor.finished())
try
{
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
catch(DataFormatException e) { }
try
{
bos.close();
}
catch(IOException e) { }
return bos.toByteArray();
}
提前致谢。