在为Oracle数据库升级jdbc驱动程序之后,我们的应用程序中的BLOB数据类型的对象反序列化失败。
在我们的应用程序中,我们在过去几年中一直使用ojdbc14而没有任何问题。但最近我们决定了 将它升级到ojdbc6。升级到这个新版本后,我们遇到了下面提到的错误 从数据库中读取(反序列化)BLOB对象。这些对象被序列化并使用旧版本的ojdbc(14)保存在数据库中。 在这里,我们尝试使用新版本的ojdbc(6)来阅读它们。
Caused by: java.io.InvalidClassException: oracle.sql.DatumWithConnection; local class incompatible: stream classdesc serialVersionUID = 491462912477014233, local class serialVersionUID = -5786207790829127167
根据错误日志,我觉得他们已经更新了oracle.sql.DatumWithConnection类中的“serialVersionUID”。 因此,当新版本的ojdbc可用时,它无法反序列化。
所以我的问题是
15:33:14,460 INFO [STDOUT] ERROR [http-10.10.10.117-8080-2] (CommonsLogger.java:38) - Exception occurred during processing request: org.apache.struts2.json.JSONException: org.hibernate.type.SerializationException: could not deserialize
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.hibernate.type.SerializationException: could not deserialize
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:246)
at org.apache.struts2.json.JSONWriter.processCustom(JSONWriter.java:178)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:168)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)
at org.apache.struts2.json.JSONWriter.write(JSONWriter.java:102)
at org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:116)
at org.apache.struts2.json.JSONResult.createJSONString(JSONResult.java:197)
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:171)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:271)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.____._____.s2.interceptor.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:40)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.custom.spring.plugin.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:199)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.struts2.json.JSONException: org.hibernate.type.SerializationException: could not deserialize
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:246)
at org.apache.struts2.json.JSONWriter.processCustom(JSONWrit
15:33:14,460 INFO [STDOUT] er.java:178)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:168)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)
at org.apache.struts2.json.JSONWriter.array(JSONWriter.java:481)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:158)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:390)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:231)
... 79 more
Caused by: org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:217)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240)
at org.hibernate.type.SerializableToBlobType.fromBytes(SerializableToBlobType.java:69)
at org.hibernate.type.SerializableToBlobType.get(SerializableToBlobType.java:61)
at org.hibernate.type.AbstractLobType.nullSafeGet(AbstractLobType.java:46)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
at org.hibernate.loader.Loader.getRow(Loader.java:1206)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:249)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:158)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:390)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:231)
... 87 more
Caused by: java.io.InvalidClassException: oracle.sql.DatumWithConnection; local class incompatible: stream classdesc serialVersionUID = 491462912477014233, local class serialVersionUID = -5786207790829127167
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:210)
... 111 more
package com._____.aixis.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import oracle.sql.BLOB;
import com._____._____.domain.interfaces.ICostFactorItem;
import com._____._____.domain.interfaces.ITariffTypeCategory;
@Entity
@Table(name="______Docs")
public class Document extends DomainDefault implements Serializable,ITariffTypeCategory , ICostFactorItem {
private static final long serialVersionUID = 5425465600991463936L;
private Integer id;
private String documentName;
private DocumentType documentType;
private String docComment;
private BLOB blobDoc;
private String extension;
private MasterData service;
private DocumentInvoiceType documentInvoiceType;
public Document() {
super();
}
public Document(String documentName, DocumentType documentType, String docComment, BLOB blobDoc, String extension,
MasterData service, Employee employee, Date createdDate) {
super();
this.documentName = documentName;
this.documentType = documentType;
this.docComment = docComment;
this.blobDoc = blobDoc;
this.extension = extension;
this.service = service;
if(employee != null){
this.setCreatedBy(employee.getAccount().getUsername());
this.setCreatedByUser(employee);
}
this.setCreatedDate(createdDate);
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDocumentName() {
return documentName;
}
public void setDocumentName(String doumentName) {
this.documentName = doumentName;
}
public DocumentType getDocumentType() {
return documentType;
}
public void setDocumentType(DocumentType documentType) {
this.documentType = documentType;
}
public String getDocComment() {
return docComment;
}
public void setDocComment(String docComment) {
this.docComment = docComment;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
@Transient
public String getCommonName() {
return this.documentName +"-[" + this.documentType+"]";
}
@Transient
public String getItemName() {
return this.documentName +"-[" + this.documentType+"]";
}
@Lob
public BLOB getBlobDoc() {
return blobDoc;
}
public void setBlobDoc(BLOB blobDoc) {
this.blobDoc = blobDoc;
}
@Override
public String getCreatedBy() {
return createdBy;
}
@Override
public Date getCreatedDate() {
return createdDate;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
@Override
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
@Override
public String getModifiedBy() {
return modifiedBy;
}
@Override
public Date getModifiedDate() {
return modifiedDate;
}
@Override
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
@Override
public void setModifiedDate(Date modifiedDate) {
this.modifiedDate = modifiedDate;
}
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE },fetch=FetchType.LAZY)
public MasterData getService() {
return service;
}
public void setService(MasterData service) {
this.service = service;
}
public DocumentInvoiceType getDocumentInvoiceType() {
return documentInvoiceType;
}
public void setDocumentInvoiceType(DocumentInvoiceType documentInvoiceType) {
this.documentInvoiceType = documentInvoiceType;
}
@Override
@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.PERSIST)
public Person getCreatedByUser() {
return createdByUser;
}
@Override
public void setCreatedByUser(Person createdBy) {
this.createdByUser = createdBy;
}
@Override
@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.PERSIST)
public Person getModifiedByUser() {
return modifiedByUser;
}
@Override
public void setModifiedByUser(Person modifiedBy) {
this.modifiedByUser = modifiedBy;
}
}
答案 0 :(得分:1)
**如果您赶时间,只需下载自定义的ojdbc6.jar文件并使用它。你不必做任何其他事情。
https://drive.google.com/open?id=0Bz2PT96Cb0tSRk5XNGU3TUdHS1U
我的答案摘要
首先,反编译下面提到的类。
•oracle.sql.DatumWithConnection.class
•oracle.sql.BLOB.class
然后将旧的serialVersionUID添加到这些类中。(错误日志中提供旧版本的ID)
如果您想手动构建JAR,请阅读并遵循下面提到的说明。
首先,在ojdbc6.jar文件中反编译下面提到的类。
•oracle.sql.DatumWithConnection.class
•oracle.sql.BLOB.class
要进行反编译,您可以使用" Java Decompiler"在http://jd.benow.ca/
(当从数据库中读取已保存的BLOB对象时,这些是给出麻烦的类。)
如果要创建新项目,请使用正确的打包结构(oracle.sql)添加反编译的java文件。 此外,您还必须将ojdbc6.jar文件添加到此项目的构建路径中。
然后将旧的serialVersionUID添加到这些反编译的java文件中。 (编译这些java文件也需要进行其他更改。请参阅下面更新的java文件)
DatumWithConnection.java -> private static final long serialVersionUID = 491462912477014233L;
BLOB.java -> private static final long serialVersionUID = 2160152488501369185L;
之后,构建项目并获取重新编译的类。
最后使用新类更新ojdbc6.jar以获得升级和自定义的ojdbc库。就是这样
5.1创建一个名为"更新JAR"。
的新文件夹5.2将ojdbc6.jar文件复制到该文件夹中。 D:\ JARS \更新了JAR \ ojdbc.jar
5.3在该文件夹下创建两个新文件夹来构建类文件的包结构(\ oracle \ sql)
5.4将两个类文件添加到" sql"文件夹中。
D:\JARS\Updated JAR\oracle\sql\DatumWithConnection.class
D:\JARS\Updated JAR\oracle\sql\BLOB.class
5.5打开新的命令行并将目录(cd)更改为jar文件所在的位置。
>cd D:\JARS\Updated JAR
5.6要使用新的类文件更新jar文件,请在命令行中使用下面提到的命令。
>jar uf ojdbc6.jar oracle\sql\DatumWithConnection.class
>jar uf ojdbc6.jar oracle\sql\BLOB.class
5.7现在你有了一个自定义的ojdbc6.jar文件,该文件可以与使用ojdbc14.jar序列化并保存的BLOB对象一起使用
更新了java类。
DatumWithConnection.java
package oracle.sql;
import java.sql.Connection;
import java.sql.SQLException;
import oracle.jdbc.driver.DatabaseError;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.internal.OracleDatumWithConnection;
public abstract class DatumWithConnection
extends Datum
implements OracleDatumWithConnection
{
private static final long serialVersionUID = 491462912477014233L;
private oracle.jdbc.internal.OracleConnection physicalConnection = null;
oracle.jdbc.internal.OracleConnection getPhysicalConnection()
{
if (this.physicalConnection == null) {
try
{
this.physicalConnection = ((oracle.jdbc.internal.OracleConnection)new OracleDriver().defaultConnection());
}
catch (SQLException localSQLException) {}
}
return this.physicalConnection;
}
public DatumWithConnection(byte[] paramArrayOfByte)
throws SQLException
{
super(paramArrayOfByte);
}
public DatumWithConnection() {}
public static void assertNotNull(Connection paramConnection)
throws SQLException
{
if (paramConnection == null)
{
SQLException localSQLException = DatabaseError.createSqlException(null, 68, "Connection is null");
localSQLException.fillInStackTrace();
throw localSQLException;
}
}
public static void assertNotNull(TypeDescriptor paramTypeDescriptor)
throws SQLException
{
if (paramTypeDescriptor == null)
{
SQLException localSQLException = DatabaseError.createSqlException(null, 61);
localSQLException.fillInStackTrace();
throw localSQLException;
}
}
public void setPhysicalConnectionOf(Connection paramConnection)
{
this.physicalConnection = ((oracle.jdbc.OracleConnection)paramConnection).physicalConnectionWithin();
}
public Connection getJavaSqlConnection()
throws SQLException
{
return getPhysicalConnection().getWrapper();
}
public oracle.jdbc.OracleConnection getOracleConnection()
throws SQLException
{
return getPhysicalConnection().getWrapper();
}
public oracle.jdbc.internal.OracleConnection getInternalConnection()
throws SQLException
{
return getPhysicalConnection();
}
/**
* @deprecated
*/
public oracle.jdbc.driver.OracleConnection getConnection()
throws SQLException
{
oracle.jdbc.driver.OracleConnection localOracleConnection = null;
try
{
localOracleConnection = (oracle.jdbc.driver.OracleConnection)((oracle.jdbc.driver.OracleConnection)this.physicalConnection).getWrapper();
}
catch (ClassCastException localClassCastException)
{
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 103);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return localOracleConnection;
}
protected oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()
{
return this.physicalConnection;
}
private static final String _Copyright_2007_Oracle_All_Rights_Reserved_ = null;
public static final boolean TRACE = false;
}
BLOB.java
package oracle.sql;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.SQLException;
import oracle.jdbc.LargeObjectAccessMode;
import oracle.jdbc.driver.DatabaseError;
import oracle.jdbc.internal.OracleBlob;
public class BLOB extends DatumWithConnection implements OracleBlob {
private static final long serialVersionUID = 2160152488501369185L;
public static final int MAX_CHUNK_SIZE = 32768;
public static final int DURATION_SESSION = 10;
public static final int DURATION_CALL = 12;
static final int OLD_WRONG_DURATION_SESSION = 1;
static final int OLD_WRONG_DURATION_CALL = 2;
public static final int MODE_READONLY = 0;
public static final int MODE_READWRITE = 1;
BlobDBAccess dbaccess;
int dbChunkSize;
boolean isFree;
boolean fromObject;
private long cachedLobLength;
private byte[] prefetchData;
private int prefetchDataSize;
private boolean activePrefetch;
static final int KDLCTLSIZE = 16;
static final int KDF_FLAG = 88;
static final int KDLIDDAT = 8;
private static final String _Copyright_2007_Oracle_All_Rights_Reserved_ = null;
public static final boolean TRACE = false;
public static Object localObject;
protected BLOB() {
this.dbChunkSize = -1;
this.isFree = false;
this.fromObject = false;
this.cachedLobLength = -1L;
this.prefetchDataSize = 0;
this.activePrefetch = false;
}
public BLOB(oracle.jdbc.OracleConnection paramOracleConnection) throws SQLException {
this(paramOracleConnection, null);
}
public BLOB(oracle.jdbc.OracleConnection paramOracleConnection, byte[] paramArrayOfByte, boolean paramBoolean)
throws SQLException {
this(paramOracleConnection, paramArrayOfByte);
this.fromObject = paramBoolean;
}
public BLOB(oracle.jdbc.OracleConnection paramOracleConnection, byte[] paramArrayOfByte) throws SQLException {
super(paramArrayOfByte);
this.dbChunkSize = -1;
this.isFree = false;
this.fromObject = false;
this.cachedLobLength = -1L;
this.prefetchDataSize = 0;
this.activePrefetch = false;
assertNotNull(paramOracleConnection);
setPhysicalConnectionOf(paramOracleConnection);
this.dbaccess = getPhysicalConnection().createBlobDBAccess();
this.dbaccess.incrementTempLobReferenceCount(paramArrayOfByte);
}
public long length() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
long l = -1L;
if ((this.activePrefetch) && (this.cachedLobLength != -1L))
l = this.cachedLobLength;
else if (canReadBasicLobDataInLocator())
l = dilLength();
else
l = getDBAccess().length(this);
return l;
}
public byte[] getBytes(long paramLong, int paramInt) throws SQLException {
if (this.isFree) {
localObject = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 192);
((SQLException) localObject).fillInStackTrace();
throw ((SQLException) localObject);
}
if ((paramInt < 0) || (paramLong < 1L)) {
localObject = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 68, "getBytes()");
((SQLException) localObject).fillInStackTrace();
throw ((SQLException) localObject);
}
if (canReadBasicLobDataInLocator()) {
return dilGetBytes(paramLong, paramInt);
}
Object localObject = null;
if (paramInt == 0) {
return new byte[0];
}
if ((this.activePrefetch) && (((this.cachedLobLength == 0L)
|| ((this.cachedLobLength > 0L) && (paramLong - 1L >= this.cachedLobLength))))) {
localObject = null;
} else {
long l = 0L;
byte[] arrayOfByte;
if ((this.activePrefetch) && (this.cachedLobLength != -1L))
arrayOfByte = new byte[Math.min((int) this.cachedLobLength, paramInt)];
else {
arrayOfByte = new byte[paramInt];
}
l = getBytes(paramLong, paramInt, arrayOfByte);
if (l > 0L) {
if (l == paramInt) {
localObject = arrayOfByte;
} else {
localObject = new byte[(int) l];
System.arraycopy(arrayOfByte, 0, localObject, 0, (int) l);
}
}
}
return ((byte[])localObject);
}
public InputStream getBinaryStream() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
if (canReadBasicLobDataInLocator()) {
return dilGetBinaryStream(1L);
}
return getDBAccess().newInputStream(this, getBufferSize(), 0L);
}
public long position(byte[] paramArrayOfByte, long paramLong) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().position(this, paramArrayOfByte, paramLong);
}
public long position(Blob paramBlob, long paramLong) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().position(this, (BLOB) paramBlob, paramLong);
}
public int getBytes(long paramLong, int paramInt, byte[] paramArrayOfByte) throws SQLException {
SQLException localSQLException;
if (this.isFree) {
localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
if ((paramInt < 0) || (paramLong < 0L)) {
localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 68,
"getBytes()");
localSQLException.fillInStackTrace();
throw localSQLException;
}
if (paramArrayOfByte.length < paramInt) {
paramInt = paramArrayOfByte.length;
}
return getDBAccess().getBytes(this, paramLong, paramInt, paramArrayOfByte);
}
public int putBytes(long paramLong, byte[] paramArrayOfByte) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return setBytes(paramLong, paramArrayOfByte);
}
public int putBytes(long paramLong, byte[] paramArrayOfByte, int paramInt) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return setBytes(paramLong, paramArrayOfByte, 0, paramInt);
}
public OutputStream getBinaryOutputStream() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return setBinaryStream(1L);
}
public byte[] getLocator() {
return getBytes();
}
public void setLocator(byte[] paramArrayOfByte) {
setBytes(paramArrayOfByte);
}
public int getChunkSize() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
if (this.dbChunkSize <= 0) {
this.dbChunkSize = getDBAccess().getChunkSize(this);
}
return this.dbChunkSize;
}
public int getBufferSize() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
int i = getChunkSize();
int j = i;
if ((i >= 32768) || (i <= 0)) {
j = 32768;
} else {
j = 32768 / i * i;
}
return j;
}
public static BLOB empty_lob() throws SQLException {
return getEmptyBLOB();
}
public static BLOB getEmptyBLOB() throws SQLException {
byte[] arrayOfByte = new byte[86];
arrayOfByte[1] = 84;
arrayOfByte[5] = 24;
BLOB localBLOB = new BLOB();
localBLOB.setShareBytes(arrayOfByte);
return localBLOB;
}
public boolean isEmptyLob() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
boolean bool = (shareBytes()[5] & 0x10) != 0;
return bool;
}
public boolean isSecureFile() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
boolean bool = (shareBytes()[7] & 0xFFFFFF80) != 0;
return bool;
}
public OutputStream getBinaryOutputStream(long paramLong) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().newOutputStream(this, getBufferSize(), paramLong, false);
}
public InputStream getBinaryStream(long paramLong) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
if (canReadBasicLobDataInLocator()) {
return dilGetBinaryStream(paramLong);
}
return getDBAccess().newInputStream(this, getBufferSize(), paramLong);
}
public void trim(long paramLong) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
truncate(paramLong);
}
public static BLOB createTemporary(Connection paramConnection, boolean paramBoolean, int paramInt)
throws SQLException {
int i = paramInt;
if (paramInt == 1) {
i = 10;
}
if (paramInt == 2) {
i = 12;
}
if ((paramConnection == null) || ((i != 10) && (i != 12))) {
localObject = DatabaseError.createSqlException(null, 68,
"'conn' should not be null and 'duration' should either be equal to DURATION_SESSION or to DURATION_CALL");
((SQLException) localObject).fillInStackTrace();
throw ((SQLException) localObject);
}
Object localObject = ((oracle.jdbc.OracleConnection) paramConnection).physicalConnectionWithin();
return ((BLOB) getDBAccess((Connection) localObject).createTemporaryBlob((Connection) localObject, paramBoolean,
i));
}
public static void freeTemporary(BLOB paramBLOB) throws SQLException {
if (paramBLOB == null) {
return;
}
paramBLOB.freeTemporary();
}
public static boolean isTemporary(BLOB paramBLOB) throws SQLException {
if (paramBLOB == null) {
return false;
}
return paramBLOB.isTemporary();
}
public void freeTemporary() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
int i = getDBAccess().decrementTempLobReferenceCount(shareBytes());
if (i == 0)
getDBAccess().freeTemporary(this, this.fromObject);
}
public boolean isTemporary() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().isTemporary(this);
}
public void open(LargeObjectAccessMode paramLargeObjectAccessMode) throws SQLException {
open(paramLargeObjectAccessMode.getCode());
}
public void open(int paramInt) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
getDBAccess().open(this, paramInt);
}
public void close() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
getDBAccess().close(this);
}
public boolean isOpen() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().isOpen(this);
}
public int setBytes(long paramLong, byte[] paramArrayOfByte) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().putBytes(this, paramLong, paramArrayOfByte, 0,
(paramArrayOfByte != null) ? paramArrayOfByte.length : 0);
}
public int setBytes(long paramLong, byte[] paramArrayOfByte, int paramInt1, int paramInt2) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().putBytes(this, paramLong, paramArrayOfByte, paramInt1, paramInt2);
}
public OutputStream setBinaryStream(long paramLong) throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return getDBAccess().newOutputStream(this, getBufferSize(), paramLong, true);
}
public void truncate(long paramLong) throws SQLException {
SQLException localSQLException;
if (this.isFree) {
localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
if (paramLong < 0L) {
localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 68,
"'len' should be >= 0. ");
localSQLException.fillInStackTrace();
throw localSQLException;
}
getDBAccess().trim(this, paramLong);
}
public Object toJdbc() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return this;
}
public boolean isConvertibleTo(Class paramClass) {
String str = paramClass.getName();
return ((str.compareTo("java.io.InputStream") == 0) || (str.compareTo("java.io.Reader") == 0));
}
public Reader characterStreamValue() throws SQLException {
getInternalConnection();
return getDBAccess().newConversionReader(this, 8);
}
public InputStream asciiStreamValue() throws SQLException {
getInternalConnection();
return getDBAccess().newConversionInputStream(this, 2);
}
public InputStream binaryStreamValue() throws SQLException {
return getBinaryStream();
}
public Object makeJdbcArray(int paramInt) {
return new BLOB[paramInt];
}
public BlobDBAccess getDBAccess() throws SQLException {
SQLException localSQLException;
if (this.dbaccess == null) {
if (isEmptyLob()) {
localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 98);
localSQLException.fillInStackTrace();
throw localSQLException;
}
this.dbaccess = getInternalConnection().createBlobDBAccess();
}
if (getPhysicalConnection().isClosed()) {
localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 8);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return this.dbaccess;
}
public static BlobDBAccess getDBAccess(Connection paramConnection) throws SQLException {
return ((oracle.jdbc.OracleConnection) paramConnection).physicalConnectionWithin().createBlobDBAccess();
}
public Connection getJavaSqlConnection() throws SQLException {
if (this.isFree) {
SQLException localSQLException = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException.fillInStackTrace();
throw localSQLException;
}
return super.getJavaSqlConnection();
}
public final void setLength(long paramLong) {
this.cachedLobLength = paramLong;
}
public final void setChunkSize(int paramInt) {
this.dbChunkSize = paramInt;
}
public final void setPrefetchedData(byte[] paramArrayOfByte) {
if (paramArrayOfByte == null)
setPrefetchedData(null, 0);
else
setPrefetchedData(paramArrayOfByte, paramArrayOfByte.length);
}
public final void setPrefetchedData(byte[] paramArrayOfByte, int paramInt) {
this.prefetchData = paramArrayOfByte;
this.prefetchDataSize = paramInt;
}
public final byte[] getPrefetchedData() {
return this.prefetchData;
}
public final int getPrefetchedDataSize() {
return this.prefetchDataSize;
}
public final void setActivePrefetch(boolean paramBoolean) {
if ((this.activePrefetch) && (!(paramBoolean)))
clearCachedData();
this.activePrefetch = paramBoolean;
}
public final void clearCachedData() {
this.cachedLobLength = -1L;
this.prefetchData = null;
}
public final boolean isActivePrefetch() {
return this.activePrefetch;
}
boolean canReadBasicLobDataInLocator() throws SQLException {
byte[] arrayOfByte = shareBytes();
if ((arrayOfByte == null) || (arrayOfByte.length < 102)) {
return false;
}
if (!getPhysicalConnection().isDataInLocatorEnabled()) {
return false;
}
int i = arrayOfByte[6] & 0xFF;
int j = arrayOfByte[7] & 0xFF;
int k = (i & 0x8) == 8 ? 1 : 0;
int m = (j & 0xFFFFFF80) == -128 ? 1 : 0;
int n = 0;
if ((k != 0) && (m == 0))
{
n = ((arrayOfByte[88] & 0xFF) & 0x8) == 8 ? 1 : 0;
}
return (k != 0) && (m == 0) && (n != 0);
}
int dilLength() {
return (shareBytes().length - 86 - 16);
}
byte[] dilGetBytes(long paramLong, int paramInt) throws SQLException {
if (paramInt == 0) {
return new byte[0];
}
if (dilLength() == 0) {
return null;
}
int i = (int) Math.min(paramInt, dilLength() - (paramLong - 1L));
if (i <= 0) {
return null;
}
byte[] arrayOfByte = new byte[i];
System.arraycopy(shareBytes(), (int) (paramLong - 1L) + 86 + 16, arrayOfByte, 0, i);
return arrayOfByte;
}
InputStream dilGetBinaryStream(long paramLong) throws SQLException {
if (paramLong < 0L) {
throw new IllegalArgumentException("Illegal Arguments");
}
byte[] arrayOfByte = dilGetBytes(paramLong, dilLength());
if (arrayOfByte == null) {
arrayOfByte = new byte[0];
}
return new ByteArrayInputStream(arrayOfByte);
}
public void free() throws SQLException {
if (this.isFree)
return;
if (isOpen())
close();
if (isTemporary())
freeTemporary();
this.isFree = true;
this.dbaccess = null;
}
public InputStream getBinaryStream(long paramLong1, long paramLong2) throws SQLException {
if (this.isFree) {
SQLException localSQLException1 = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
192);
localSQLException1.fillInStackTrace();
throw localSQLException1;
}
if (canReadBasicLobDataInLocator()) {
return dilGetBinaryStream(paramLong1, paramLong2);
}
long l = length();
if ((paramLong1 < 1L) || (paramLong2 < 0L) || (paramLong1 > l) || (paramLong1 - 1L + paramLong2 > l)) {
SQLException localSQLException2 = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(),
68);
localSQLException2.fillInStackTrace();
throw localSQLException2;
}
return getDBAccess().newInputStream(this, getChunkSize(), paramLong1, paramLong2);
}
InputStream dilGetBinaryStream(long paramLong1, long paramLong2) throws SQLException {
int i = dilLength();
if ((paramLong1 < 1L) || (paramLong2 < 0L) || (paramLong1 > i) || (paramLong1 - 1L + paramLong2 > i)) {
localObject = DatabaseError.createSqlException(getConnectionDuringExceptionHandling(), 68);
((SQLException) localObject).fillInStackTrace();
throw ((SQLException) localObject);
}
byte[] localObject = dilGetBytes(paramLong1, i - (int) (paramLong1 - 1L));
return ((InputStream) new ByteArrayInputStream(localObject, 0, (int) paramLong2));
}
}