ClassCastException w/ BLOB
We are currently using v 2.5.2 and have run into a problem when attempting
to insert a BLOB using WebLogic (via EJB). When I run a stand-alone test
case, everything works as planned. The BLOB is inserted with no problems.
However, if I change the test case to call an EJB deployed on WebLogic
8.1 (which in turn calls the same functionality to insert the BLOB via
KODO), a receive the following exception:
NestedThrowablesStackTrace:
java.lang.ClassCastException
at
com.solarmetric.kodo.impl.jdbc.ormapping.OracleBlobMapping.update(OracleBlobMapping.java:100)
at
com.solarmetric.kodo.impl.jdbc.ormapping.OracleBlobMapping.insert(OracleBlobMapping.java:73)
at
com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.java:437)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:530)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.java:697)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:422)
at
com.iits.sdb.app.facade.MaintainProducerRequestFacade.addProducerRequest(MaintainProducerRequestFacade.java:99)
at
com.iits.sdb.app.delegate.MaintainProducerRequestDelegate.addProducerRequest(MaintainProducerRequestDelegate.java:89)
at
com.iits.ejb.RequestProcessBean.persistRequest(RequestProcessBean.java:333)
at
com.iits.ejb.RequestProcessBean.prepareAddInitialAppointment(RequestProcessBean.java:125)
at
com.iits.ejb.RequestProcessEjb_pfomyb_EOImpl.prepareAddInitialAppointment(RequestProcessEjb_pfomyb_EOImpl.java:150)
at
com.iits.ejb.RequestProcessEjb_pfomyb_EOImpl_WLSkel.invoke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Any help would be greatly appreciated.
Marc,
After doing some additional investigation, the following link provides
more insight into why the error occurred.
http://e-docs.bea.com/wls/docs70/jdbc/thirdparty.html#1045809
It seems like adding a conditional cast to weblogic's wrapper class,
weblogic.jdbc.vendor.oracle.OracleThinBlob, would fix the issue in
OracleBlobMapping. Is there a recommended way for us to add this
functionality, to enable us to still use Kodo for BLOB's in WebLogic?
Thanks,
Josh
Josh Zook wrote:
After trying your suggestion below, I still run into the same issue (see
stack trace below). However, after looking at the generated SQL, it
appears that Kodo is trying to INSERT the blob, rather than use
EMPTY_BLOB() and then SELECT FOR UPDATE. I don't think upgrading is 3.0
is an option for us at this time. Please let me know if you can think of
anything else.
Thanks,
Josh
java.sql.SQLException: Data size bigger than max size for this type: 4036
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:95)
at
oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2413)
at
oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1166)
at
oracle.jdbc.driver.OraclePreparedStatement.setBinaryStream(OraclePreparedStatement.java:2598)
at
weblogic.jdbc.wrapper.PreparedStatement.setBinaryStream(PreparedStatement.java:289)
at
com.iits.pulsar.jdo.OracleDictionary.blobToPreparedParameter(OracleDictionary.java:76)
Marc Prud'hommeaux wrote:
Josh-
The problem is that the Oracle JDBC drivers require special handling for
blobs over a certain size: they need to have Oracle-specific BLOB/CLOB
classes. Unfortunately, when another DataSource wraps the oracle
DataSource, there isn't much we can do.
Kodo 3.0 has a better way of doing this that will probably work around
your problem. If you don't want to upgrade to 3.0 RC 1, then you
could try to subclass OracleDictionary with your own class that
overrides AbstractDictionary.blobToPreparedParameter. I have read that
some versions of the Oracle driver will handle a direct blob better if
you call stmnt.setBinaryStream(index, new ByteArrayInputStram (bytes))
the if you do stmnt.setObject(index, ob) (which is the default way we
deal with this).
Please let us know if you still have problems after trying this.
In article <[email protected]>, Josh Zook wrote:
Thanks for the help. Yes, we are using WebLogic datasource, so that is
the root of the problem. My standalone test case was using Kodo intenal
connection pooling. It looks like WebLogic datasource wraps the
ResultSet
and Blob in it's own classes (perhaps causing the cast exception?).
I tried you advice and set isOracleJDBCDriver=false. I now get the
exception listed below. Any suggestions would be appreciated.
java.sql.SQLException: Data size bigger than max size for this type: 4009
atoracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
atoracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:95)
at
oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2413)
at
oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1166)
at
oracle.jdbc.driver.OraclePreparedStatement.setBytes(OraclePreparedStatement.java:2208)
at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:3002)
at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:3217)
at
weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:172)
at
com.solarmetric.kodo.impl.jdbc.schema.dict.AbstractDictionary.blobToPreparedParameter(AbstractDictionary.java:1110)
at
com.solarmetric.kodo.impl.jdbc.schema.dict.OracleDictionary.blobToPreparedParameter(OracleDictionary.java:203)
at
com.solarmetric.kodo.impl.jdbc.schema.dict.AbstractDictionary.toPreparedParameter(AbstractDictionary.java:840)
at
com.solarmetric.kodo.impl.jdbc.sql.SQLValue.applyParameter(SQLValue.java:129)
at
com.solarmetric.kodo.impl.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java:239)
at
com.solarmetric.kodo.impl.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java:222)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.prepareStatementInternal(SQLExecutionManagerImpl.java:753)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementNonBatch(SQLExecutionManagerImpl.java:445)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:423)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:381)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:255)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:554)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.java:697)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:422)
at
com.iits.sdb.app.facade.MaintainProducerRequestFacade.addProducerRequest(MaintainProducerRequestFacade.java:106)
>>>
>>>
Marc Prud'hommeaux wrote:
Josh-
Are you using Kodo's own DataSource in the Weblogic environment, or are
you using a DataSource bound into WebLogic's JNDI? If the latter, then
it may be that our special blob handling for Oracle is having problems
with WebLogic's DataSource.
One thing you might try to do is set the DictionaryProperties to have
"isOracleJDBCDriver=false", which should prevent Kodo from using it's
special Oracle driver behavior.
In article <[email protected]>, Josh Zook wrote:
We are currently using v 2.5.2 and have run into a problem when
attempting
to insert a BLOB using WebLogic (via EJB). When I run a stand-alonetest
case, everything works as planned. The BLOB is inserted with noproblems.
However, if I change the test case to call an EJB deployed on
WebLogic
8.1 (which in turn calls the same functionality to insert the BLOB via
KODO), a receive the following exception:
NestedThrowablesStackTrace:
java.lang.ClassCastException
at
com.solarmetric.kodo.impl.jdbc.ormapping.OracleBlobMapping.update(OracleBlobMapping.java:100)
at
com.solarmetric.kodo.impl.jdbc.ormapping.OracleBlobMapping.insert(OracleBlobMapping.java:73)
at
com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.java:437)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:530)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.java:697)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:422)
at
com.iits.sdb.app.facade.MaintainProducerRequestFacade.addProducerRequest(MaintainProducerRequestFacade.java:99)
at
com.iits.sdb.app.delegate.MaintainProducerRequestDelegate.addProducerRequest(MaintainProducerRequestDelegate.java:89)
at
com.iits.ejb.RequestProcessBean.persistRequest(RequestProcessBean.java:333)
at
com.iits.ejb.RequestProcessBean.prepareAddInitialAppointment(RequestProcessBean.java:125)
at
com.iits.ejb.RequestProcessEjb_pfomyb_EOImpl.prepareAddInitialAppointment(RequestProcessEjb_pfomyb_EOImpl.java:150)
at
com.iits.ejb.RequestProcessEjb_pfomyb_EOImpl_WLSkel.invoke(UnknownSource)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
atweblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Any help would be greatly appreciated.
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com
Similar Messages
-
ClassCastException reading blobs from MySQL
Hi,
When reading a blob (byte array) field from mysql I get a ClassCastException
exception.
Both using mysql 3.3.56 or 4.0.12 with jdbc driver 2.0.14 or 3.0.7, I get
the same error.
The same code works fine using other (sql-server, oracle) databases.
Any ideas?
configuration:
kodo 2.4.3
jdk 1.4.1-02
jboss 3.0.4
windows 2000
2003-05-15 11:22:21,123 ERROR [STDERR] javax.jdo.JDOException:
java.lang.ClassCastException
NestedThrowables:
java.lang.ClassCastException
2003-05-15 11:22:21,123 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.jav
a:2043)
2003-05-15 11:22:21,123 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java
:720)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.jdoGetinputParamBytes(ActionInstance.java)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.getInputParams(ActionInstance.java:215)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.ejb.TransientServiceManager.findAction(TransientServiceMan
ager.java:481)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.dispatch.DispatchMDB.onMessage(DispatchMDB.java:256)
2003-05-15 11:22:21,123 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2003-05-15 11:22:21,123 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
2003-05-15 11:22:21,123 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
2003-05-15 11:22:21,133 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDriv
enContainer.java:391)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:186)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenI
nstanceInterceptor.java:88)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
..java:107)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:237)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityIntercept
or.java:100)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:302)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.jav
a:971)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(
JMSContainerInvoker.java:1047)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:243)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageCons
umer.java:637)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:443)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.mq.SpySession.run(SpySession.java:297)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:178)
2003-05-15 11:22:21,133 ERROR [STDERR] at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.ja
va:732)
2003-05-15 11:22:21,133 ERROR [STDERR] at
java.lang.Thread.run(Thread.java:536)
2003-05-15 11:22:21,133 ERROR [STDERR] NestedThrowablesStackTrace:
2003-05-15 11:22:21,133 ERROR [STDERR] java.lang.ClassCastException
2003-05-15 11:22:21,133 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.jdoReplaceField(ActionInstance.java)
2003-05-15 11:22:21,133 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.replaceField(StateManagerImpl.
java:2157)
2003-05-15 11:22:21,133 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.storeObjectField(StateManagerI
mpl.java:1617)
2003-05-15 11:22:21,133 ERROR [STDERR] at
com.solarmetric.kodo.impl.jdbc.ormapping.LobMapping.load(LobMapping.java:75)
2003-05-15 11:22:21,143 ERROR [STDERR] at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.load(JDBCStoreManage
r.java:375)
2003-05-15 11:22:21,143 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.jav
a:2035)
2003-05-15 11:22:21,143 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java
:720)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.jdoGetinputParamBytes(ActionInstance.java)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.getInputParams(ActionInstance.java:215)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.ejb.TransientServiceManager.findAction(TransientServiceMan
ager.java:481)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.dispatch.DispatchMDB.onMessage(DispatchMDB.java:256)
2003-05-15 11:22:21,143 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2003-05-15 11:22:21,143 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
2003-05-15 11:22:21,143 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
2003-05-15 11:22:21,143 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDriv
enContainer.java:391)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:186)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenI
nstanceInterceptor.java:88)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
..java:107)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:237)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityIntercept
or.java:100)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:302)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.jav
a:971)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(
JMSContainerInvoker.java:1047)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:243)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageCons
umer.java:637)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:443)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.mq.SpySession.run(SpySession.java:297)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:178)
2003-05-15 11:22:21,143 ERROR [STDERR] at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.ja
va:732)
2003-05-15 11:22:21,143 ERROR [STDERR] at
java.lang.Thread.run(Thread.java:536)Jesper-
Strange. What is the type of the field? Is it a byte array? There are
some special workarounds in the MySQLDictionary class to get around bugs
in the MySQL JDBC driver, that might be conflicting with your field
type.
In article <[email protected]>, Jesper Ladegaard wrote:
Hi,
When reading a blob (byte array) field from mysql I get a ClassCastException
exception.
Both using mysql 3.3.56 or 4.0.12 with jdbc driver 2.0.14 or 3.0.7, I get
the same error.
The same code works fine using other (sql-server, oracle) databases.
Any ideas?
configuration:
kodo 2.4.3
jdk 1.4.1-02
jboss 3.0.4
windows 2000
2003-05-15 11:22:21,123 ERROR [STDERR] javax.jdo.JDOException:
java.lang.ClassCastException
NestedThrowables:
java.lang.ClassCastException
2003-05-15 11:22:21,123 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.jav
a:2043)
2003-05-15 11:22:21,123 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java
:720)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.jdoGetinputParamBytes(ActionInstance.java)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.getInputParams(ActionInstance.java:215)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.ejb.TransientServiceManager.findAction(TransientServiceMan
ager.java:481)
2003-05-15 11:22:21,123 ERROR [STDERR] at
dk.pine.enactment.dispatch.DispatchMDB.onMessage(DispatchMDB.java:256)
2003-05-15 11:22:21,123 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2003-05-15 11:22:21,123 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
2003-05-15 11:22:21,123 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
2003-05-15 11:22:21,133 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDriv
enContainer.java:391)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:186)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenI
nstanceInterceptor.java:88)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
.java:107)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:237)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityIntercept
or.java:100)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:302)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.jav
a:971)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(
JMSContainerInvoker.java:1047)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:243)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageCons
umer.java:637)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:443)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.mq.SpySession.run(SpySession.java:297)
2003-05-15 11:22:21,133 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:178)
2003-05-15 11:22:21,133 ERROR [STDERR] at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.ja
va:732)
2003-05-15 11:22:21,133 ERROR [STDERR] at
java.lang.Thread.run(Thread.java:536)
2003-05-15 11:22:21,133 ERROR [STDERR] NestedThrowablesStackTrace:
2003-05-15 11:22:21,133 ERROR [STDERR] java.lang.ClassCastException
2003-05-15 11:22:21,133 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.jdoReplaceField(ActionInstance.java)
2003-05-15 11:22:21,133 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.replaceField(StateManagerImpl.
java:2157)
2003-05-15 11:22:21,133 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.storeObjectField(StateManagerI
mpl.java:1617)
2003-05-15 11:22:21,133 ERROR [STDERR] at
com.solarmetric.kodo.impl.jdbc.ormapping.LobMapping.load(LobMapping.java:75)
2003-05-15 11:22:21,143 ERROR [STDERR] at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.load(JDBCStoreManage
r.java:375)
2003-05-15 11:22:21,143 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.jav
a:2035)
2003-05-15 11:22:21,143 ERROR [STDERR] at
com.solarmetric.kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java
:720)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.jdoGetinputParamBytes(ActionInstance.java)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.ActionInstance.getInputParams(ActionInstance.java:215)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.ejb.TransientServiceManager.findAction(TransientServiceMan
ager.java:481)
2003-05-15 11:22:21,143 ERROR [STDERR] at
dk.pine.enactment.dispatch.DispatchMDB.onMessage(DispatchMDB.java:256)
2003-05-15 11:22:21,143 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2003-05-15 11:22:21,143 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
2003-05-15 11:22:21,143 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
2003-05-15 11:22:21,143 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDriv
enContainer.java:391)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
edConnectionInterceptor.java:186)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenI
nstanceInterceptor.java:88)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
.java:107)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
java:237)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityIntercept
or.java:100)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:302)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.jav
a:971)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(
JMSContainerInvoker.java:1047)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:243)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageCons
umer.java:637)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:443)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.mq.SpySession.run(SpySession.java:297)
2003-05-15 11:22:21,143 ERROR [STDERR] at
org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:178)
2003-05-15 11:22:21,143 ERROR [STDERR] at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.ja
va:732)
2003-05-15 11:22:21,143 ERROR [STDERR] at
java.lang.Thread.run(Thread.java:536)
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
ClassCastException while inserting in oracle.sql.BLOB
Hi,
I have to insert a blob data in to database . I wrote the code . I'm having a ClassCastException problem in the line oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_CALL); while trying to store a BLOB value I'm using Oracle 9i. (JDBC classes12.jar).
if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem .
But when I use JBoss to run , I will get ClassCastException
I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the jboss datasource. The code to save the BLOB is as follows:
String sql = " update test set code = ? where id = ? ";
BLOB newBlob = BLOB.createTemporary(dbcon, false, BLOB.DURATION_CALL);
newBlob.putBytes(1,data.getBytes());
stmt = dbcon.prepareStatement(newsql);
stmt.setBlob(1, newBlob);
stmt.setInt(2, Studid );
stmt.executeUpdate();
stmt.close();Can any one tell me how can I get this code to work with the datasource implementation.
ThanksI think this could be a problem with the class loader . Take a look at this thread It should solve your problem.
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=788715 -
Insert Blob column in the client errors ClassCastException: oracle.sql.BLOB
Hi,
When I try to insert and commit a Blob column(picture) I am getting the following exception.
Is there any jar I need to add or any other setup I need to do to accept the BLOB column in the olite client database.
500 Internal Server Error
javax.faces.FacesException: #{backing_XXPBWorkOrderResultsCreatePGBean.saveButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.sql.BLOB
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
Caused by: java.lang.ClassCastException: oracle.sql.BLOB
at oracle.lite.poljdbc.LiteEmbPreparedStmt.setVal(Unknown Source)
at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
at oracle.lite.web.JupPreparedStatement.setObject(Unknown Source)
at oracle.jbo.server.BaseSQLBuilderImpl.bindUpdateStatement(BaseSQLBuilderImpl.java:1765)
at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:7345)
With regareds,
Kali.
OSSI.Here are examples if inserting into a Blob from text, file, and retrieving a blob.
Insert into a Blob (Text)
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InsertBlob {
public static void main(String[] args) throws FileNotFoundException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
String letterText = "some letter text";
long id = 100;
try {
DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
try {
con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, EMPTY_BLOB())");
stmt.setLong(1, id);
stmt.executeUpdate();
stmt = con.prepareStatement("SELECT BLOB_DATA FROM BLOB_TABLE WHERE BLOB_ID = ? FOR UPDATE");
stmt.setLong(1, id);
rs = stmt.executeQuery();
if (rs.next()) {
try {
oracle.lite.poljdbc.BLOB oliteBlob = null;
oliteBlob = ((oracle.lite.poljdbc.OracleResultSet) rs).getBLOB(1);
byte[] byteLetterText = letterText.getBytes();
oliteBlob.putBytes(1, byteLetterText);
con.commit();
} catch (ClassCastException e) {
e.printStackTrace();
} finally {
rs = null;
stmt = null;
con.rollback();
con = null;
} catch (SQLException e) {
e.printStackTrace();
}Insert Into a Blob (File)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class InsertBlobFile {
public static void main(String[] args) throws FileNotFoundException {
Connection con = null;
PreparedStatement stmt = null;
long id = 200;
try {
DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
try {
con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, ?)");
stmt.setLong(1, id);
File fBlob = new File ( "C:\\BLOB_TEST_FILE.TXT" );
FileInputStream is = new FileInputStream ( fBlob );
stmt.setBinaryStream (2, is, (int) fBlob.length() );
stmt.executeUpdate();
con.commit();
} catch (SQLException e) {
e.printStackTrace();
}Retrieve from Blob (Write to file)
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RetrieveBlob {
final static int bBufLen = 32 * 1024;
final static String outFile = "C:\\BLOB_OUTPUT_FILE.TXT";
public static void main(String[] args) throws IOException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
try {
con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
stmt = con.prepareStatement("SELECT * FROM BLOB_TABLE");
rs = stmt.executeQuery();
while(rs.next()) {
int id = rs.getInt(1);
Blob value = rs.getBlob(2);
System.out.println(id + " | " + value);
writeBlobToFile(value);
} catch (SQLException e) {
e.printStackTrace();
public static long readFromBlob(Blob blob, OutputStream out)
throws SQLException, IOException {
InputStream in = blob.getBinaryStream();
int length = -1;
long read = 0;
byte[] buf = new byte[bBufLen];
while ((length = in.read(buf)) > 0) {
out.write(buf, 0, length);
read += length;
in.close();
return read;
public static long writeBlobToFile(Blob blob)
throws IOException, SQLException {
long wrote = 0;
OutputStream fwriter = new FileOutputStream(outFile);
wrote = readFromBlob(blob, fwriter);
fwriter.close();
return wrote;
} -
ClassCastException in oracle.sql.BLOB.createTemporary
Hi,
I'm having a ClassCastException problem using the method oracle.sql.BLOB.createTemporary while trying to store a BLOB value (JDBC classes12.jar). The problem is quite clear - if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem - if I use it with an Orion datasource shipped with Oracle IAS10g it gives me a ClassCastException. I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the Orion datasource. The code to save the BLOB is as follows:
oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_SESSION);
blob.open(BLOB.MODE_READWRITE);
OutputStream out = blob.getBinaryOutputStream();
try {
out.write((byte[])value);
out.flush();
out.close();
} catch (IOException e) {
throw new SQLException("failed write to blob" + e.getMessage());
blob.close();
((oracle.jdbc.OraclePreparedStatement)(st)).setBLOB(index, blob);
My questions are:
(1) is it possibile to save a BLOB type with a different version of Oracle JDBC without having to rely on the Oracle specific implementation of the JDBC interface (the cast of the PreparedStatement to oracle.jdbc.OraclePreparedStatement is quite ugly and not very portable!).
(2) if not, then how can I get this code to work with the datasource implementation for Oracle IAS.
thanks in advance for any help.
Dara.If you are using OCI driver, you may check whether using thin driver would avoid ClassCastException.
-
Oracle.sql.BLOB ClassCastException
Hi everyone,
I'm trying to put a serialized Java object into Oracle. I am following the example here: http://www.oracle.com/oramag/oracle/01-may/o31asktom.html
Here is my code:
String sql = "begin " +
"insert into rdm_logs (datetime, id, machine, ip_addr, action_code, tablename, comments, " +
"row_before, row_after)" +
"values (sysdate, ?, ?, ?, ?, ?, ?, empty_blob(), empty_blob()) " +
"return row_before into ?; " +
"end;";
CallableStatement stmt = connection.prepareCall(sql);
stmt.setString(1, username);
stmt.setString(2, machine);
stmt.setString(3, ip);
stmt.setString(4, action_code);
stmt.setString(5, table);
stmt.setString(6, comment);
stmt.registerOutParameter(7, java.sql.Types.BLOB);
stmt.executeUpdate();
Object o = stmt.getBlob(7);
// output class name here
System.out.println(o.getClass().toString());
// cast to oracle.sql.BLOB
oracle.sql.BLOB blob = (BLOB) o;The system output is:
class oracle.sql.BLOB
java.lang.ClassCastException: oracle.sql.BLOB
As you can see, the System.out gives oracle.sql.BLOB as the object class type, so why does it throw an exception when I cast it to be the same?
Any help would be appreciated.As you can see, the System.out gives oracle.sql.BLOB as the object
class type, so why does it throw an exception when I cast it to be the same?This can happen if the two BLOB classes have been loaded with two different unrelated class loaders. Even though the names of the classes are the same there are two separate classes.
How to fix this depends... Somehow arrange the JDBC driver to be loaded by the system class loader before any other class loader has a chance to load it? -
I get the following error when retrieving a Dealer object from DB2:
java.lang.ClassCastException: COM.ibm.db2.jdbc.net.DB2Blob
Dealer has a Profile object which is stored as a blob.
This is the DEALERX table definition:
CREATE TABLE DEALERX (JDOIDX BIGINT NOT NULL, JDOLOCKX INTEGER, JDOCLASSX
VARCHAR(255), ACCOUNTX BLOB(1M), EXTERNALIDX VARCHAR(255), IDX
VARCHAR(255),
PROFILEX BLOB(1M), PRIMARY KEY (JDOIDX));
Please note that I am able to successfully retrieve Dealer
objects with MYSQL.
DB2 server version is 7.2.3
I am using the net jdbc driver (COM.ibm.db2.jdbc.net.DB2Driver) supplied
by UBM with DB2.
Any hint?
Thank you.Claudius,
What you posted is only a partial stack trace. Could you post the full
stack trace, including the nested exception(s)?
-Patrick
Patrick Linskey
SolarMetric Inc. -
Getting ClassCastException when accessing Blob object
I am using weblogic 5.1 with service pack 10.
I need to query pdf data stored in a blob field in Oracle
8.1.6 server. The native code c:\weblogic\bin\oci816_8
is part of the path. When I query the database with
Oracle 8 client, I can get data.
driver: weblogic.jdbc20.oci.Driver
url: jdbc20:weblogic:oracle:mydb
What I have done is to get the blob object with:
Blob blob = rs.getBlob(5);
long len = blob.length();
But when I call the blob.length();
I got the a ClassCastException. I really appreicate
your comment.
The exception message is:
====================================================
java.lang.ClassCastException: java.lang.String
at weblogic.jdbc20.oci.Blob.length(Blob.java:75)
at com.agf.profile.ProfileServlet.doProcess(ProfileServlet.java:126)
at com.agf.profile.ProfileServlet.doGet(ProfileServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletSt
pl.java:120)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(Servle
textImpl.java:922)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(Servle
textImpl.java:886)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(Ser
ContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP
a:380)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
====================================================
Thanks,
Jianhi jian,
it seems you are trying to access a column as a blob type when the data in
that column is not blob.
Make sure that your column number 5 is defined as Blob in the database.
I tried the following code and it worked fine for me.
Blob b=rs.getBlob("data");
long l=b.length();
byte bt[]=b.getBytes(1,(int)b.length());
File f=new
File("d:\\bea\\wlserver6.1\\config\\jdbcdomain\\applications\\defaultwebapp\
\blob_new.pdf");
FileOutputStream fos=new FileOutputStream(f);
fos.write(bt);
fos.close();
It was able to create the file blob_new.pdf
But when I tried the following code it gave me the same exception as you are
getting
Blob bb=rs.getBlob("id");
long ll=bb.length();
Where id is a column in the database of varchar type
I am using the following settings
driver: weblogic.jdbc.oci.Driver
url: jdbc:weblogic:oracle
i am using wl 6.1 and oracle 8
Hope this helps you.
johnny
"jian zhang" <[email protected]> wrote in message
news:[email protected]...
>
I am using weblogic 5.1 with service pack 10.
I need to query pdf data stored in a blob field in Oracle
8.1.6 server. The native code c:\weblogic\bin\oci816_8
is part of the path. When I query the database with
Oracle 8 client, I can get data.
driver: weblogic.jdbc20.oci.Driver
url: jdbc20:weblogic:oracle:mydb
What I have done is to get the blob object with:
Blob blob = rs.getBlob(5);
long len = blob.length();
But when I call the blob.length();
I got the a ClassCastException. I really appreicate
your comment.
The exception message is:
====================================================
java.lang.ClassCastException: java.lang.String
at weblogic.jdbc20.oci.Blob.length(Blob.java:75)
atcom.agf.profile.ProfileServlet.doProcess(ProfileServlet.java:126)
at com.agf.profile.ProfileServlet.doGet(ProfileServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletSt
pl.java:120)
atweblogic.servlet.internal.ServletContextImpl.invokeServlet(Servle
textImpl.java:922)
atweblogic.servlet.internal.ServletContextImpl.invokeServlet(Servle
textImpl.java:886)
atweblogic.servlet.internal.ServletContextManager.invokeServlet(Ser
ContextManager.java:269)
atweblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP
a:380)
atweblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:
>
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
====================================================
Thanks,
Jian -
Weblogic 9.2 Oracle Thin Driver and BLOB/CLoB ClassCastExceptions
Hi,
I think I may be about to ask a question that has been asked many times but I'm just trying to find the definitive best approach, if any to solve this problem.
I'm working with Weblogic 9.2 on Windows. I have a couple of JDBC Oracle DataSources configured for container connection pooling and the driver that I'm using is the "Oracle's Driver (Thin) Versions 9.0.1,9.2.0,10". When retrieving a Blob from the DB we're calling
oracle.sql.BLOB.blob = (oracle.sql.BLOB)(rs.getBlob(..))
This results in a java.lang.ClassCastException: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB
The same also occurs for Clobs.
I found a link to an article written in 2003 (http://forums.bea.com/bea/message.jspa?messageID=200019959&tstart=0) that suggests writing your own OracleConnection wrapper class.
I'm just wondering does anybody know if BEA have done anything to fix this problem, we're now on Weblogic 9.2 and this issue is still occuring. I'd rather not go down the route of writing additional code just so we can tell our customers that they can run on Weblogic (when they can successfully already run on Websphere and Tomcat).
Thanks,
AoifeFor anyone who was wondering I managed to get this working though I do unfortunatley have to place a weblogic specific class in to my code :-(
Used information provided at: http://support.bea.com/application_content/product_portlets/support_patterns/wls/CLOBBLOBDataTypeHandlingIssuesPattern.html#Recommended_programming_techniques
Regards,
Aoife -
How can i read a stored picture in oracle Long Raw datatype? blob or clob?
How can i read a stored picture in oracle Long Raw datatype? Like a blob or clob?....i am using jdk 1.3
This is because...i tried to read it like a blob but i obtain a exception...about Type of column no valid......but the column exist....and it contains the long raw datatype of the pictures.....this is my code:
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import oracle.sql.BLOB;
import oracle.sql.BLOB.*;
import oracle.jdbc.driver.*;
import java.sql.*;
class rec_ima1
public static void main(String h[])
Connection con = null;
Blob bl;
final ImageIcon image1;
JPanel photo;
try
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con= DriverManager.getConnection("jdbc:oracle:thin:@123.3.12.213:1521:db_name","user","password");
String query = "Select * from pictures where ID = '18840'";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( query );
if (!rs.next())
System.out.println("Empty Result Set");
bl = rs.getBlob(5);
if (bl == null) {
System.out.println("Null Blob");
return;
InputStream is = bl.getBinaryStream();
int imageLength = (int) bl.length();
System.out.println(imageLength);
System.out.println(bl.length());
byte[] imageData = new byte [imageLength];
is.read(imageData, 0, imageLength);
image1 = new ImageIcon(imageData);
photo = new JPanel() {
public void paint(Graphics g){
g.setColor(Color.lightGray);
g.drawImage(image1.getImage(), 0, 0, this);
} catch (Exception e) {
e.printStackTrace();
Now i tried using clob:
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import oracle.sql.CLOB;
import oracle.sql.CLOB.*;
import oracle.jdbc.driver.*;
import java.sql.CallableStatement;
class rec_ima4
public static void main(String h[])
Connection con = null;
Clob cl;
JPanel photo;
try
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con= DriverManager.getConnection("jdbc:oracle:thin:@123.3.12.213:1521:db_name","user","password");
con.setAutoCommit (false);
String query = "Select * from pictures where ID = '18840'";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( query );
while (rs.next()) {
oracle.sql.CLOB clob = (CLOB) rs.getObject(5); //line 47
} catch (Exception e) {
e.printStackTrace();
This is the runtime exception:
java.lang.ClassCastException: [B
at rec_ima4.main(rec_ima4.java:47)Thanks by answering to me......
Well....i did that....but what is ImageIO?....
I declared a ImageIcon imageIO, but this give me the following:
rec_ima3.java:49: cannot resolve symbol
symbol : class BufferedImage
location: class rec_ima3
BufferedImage bi = ImageIO.read(bInput);
^
rec_ima3.java:49: cannot resolve symbol
symbol : variable ImageIO
location: class rec_ima3
BufferedImage bi = ImageIO.read(bInput);
^
What classes i have to import?.....what is ImageIO?
Thanks -
Error inserting a Blob in the database
Hi Everyone.
I have a TABLE (Oracle) which has a Blob field, when I catalogue it the data type inside the BPM is Binary.
Everything goes fine, but when I try to INSERT a row in that table I get the following exception:
Caused by: java.lang.ClassCastException: fuego.sql.BlobImpl
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStatement.java:6466)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setBlob(OraclePreparedStatementWrapper.java:126)
at fuego.jdbc.FaultTolerantPreparedStatement.setBlob(FaultTolerantPreparedStatement.java:136)
at fuego.sql.SQLUtils.setParameter(SQLUtils.java:424)
at fuego.sql.SQLObject.setFldParams(SQLObject.java:465)
at fuego.sql.SQLObject.setFldParams(SQLObject.java:455)
at fuego.sql.TableSQLObject.update(TableSQLObject.java:909)
at fuego.sql.TableSQLObject.implicitStore(TableSQLObject.java:378)
at fuego.sql.TableSQLObject.store(TableSQLObject.java:340)
at sun.reflect.GeneratedMethodAccessor480.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fuego.lang.JavaClass.invokeMethod(JavaClass.java:1410)
at fuego.sql.SQLObject.invoke(SQLObject.java:364)
at fuego.lang.Invokeable.invokeImpl(Invokeable.java:234)
at fuego.lang.Invokeable.invokeDynamic(Invokeable.java:188)
at OFERTAS_COMERCIALES.ABMOfertasNuevo.Default_1_0.Instance.CIL_testBLOG(Instance.xcdl:21)
at OFERTAS_COMERCIALES.ABMOfertasNuevo.Default_1_0.Instance.CIL_testBLOG(Instance.xcdl)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:512)
... 35 more
The statement is
TABLE.id = 1;
TABLE.contenido = at.contents
store(TABLE)
also tried:
params as Any[] = []
params[] = 1
params[] = Binary(data : at.contents).data
retVal as Int
query as String = "INSERT INTO TABLE(id, contenido) VALUES (?,?)"
extResource as String = "db"
retVal = executeUpdate(DynamicSQL, sentence : query,
implname : extResource,
inParameters : params)
and the result was the same.
The select statments works fine.
Any idea???
I'm working with Studio Version: 10.3.2 Build: #100524
Thanks in advance.
CarlosHi,
Plz check the following thread, you may have the similar issue.
Insert and Retrieve BLOB column with Oracle BPM
Bibhu -
How to use insert row with BLOB to Oracle when use connection pool?
Hi, All,
I am writing a program to store files (mapped to be a column with BLOB datatype
in the table) to Oracle database.
But I always get java.lang.ClassCastException:weblogic.jdbc.rmi.SerialBlob
Here is my code, please help. Thanks a lot!!
String sqlNewRow = "insert into documents (id, companyid, updatedate, description,
document, addby, title) ";
sqlNewRow += "values (?, ?, TO_DATE(?, 'MM/DD/YY'), ?, EMPTY_BLOB(), ?,
con.setAutoCommit(false);
ps = con.prepareStatement(sqlNewRow);
ps.setInt(1, documentid);
ps.setInt(2, companyid);
ps.setString(3, updatedate);
ps.setString(4, description);
ps.setString(5, username);
ps.setString(6, filename);
ps.executeUpdate();
ps.close();
String sqlLockRow = "select document from documents where id = ? for update";
java.sql.PreparedStatement pst = con.prepareStatement(sqlLockRow);
pst.setInt(1, documentid);
java.sql.ResultSet rset = pst.executeQuery();
rset.next();
java.sql.Blob dbBlob = rset.getBlob(1);
out.println("it's=" + dbBlob.getClass());
OutputStream dbBlobOut = ((weblogic.jdbc.vendor.oracle.OracleThinBlob)dbBlob).getBinaryOutputStream();
dbBlobOut.write(oneString.getBytes());
dbBlobOut.close();
rset.close();
pst.close();Have you defined
OutputStream dbBlobOut
as weblogic.jdbc.vendor.oralce.OracleThinBlob?
Mitesh
Almond wrote:
Hi, All,
I am writing a program to store files (mapped to be a column with BLOB datatype
in the table) to Oracle database.
But I always get java.lang.ClassCastException:weblogic.jdbc.rmi.SerialBlob
Here is my code, please help. Thanks a lot!!
String sqlNewRow = "insert into documents (id, companyid, updatedate, description,
document, addby, title) ";
sqlNewRow += "values (?, ?, TO_DATE(?, 'MM/DD/YY'), ?, EMPTY_BLOB(), ?,
con.setAutoCommit(false);
ps = con.prepareStatement(sqlNewRow);
ps.setInt(1, documentid);
ps.setInt(2, companyid);
ps.setString(3, updatedate);
ps.setString(4, description);
ps.setString(5, username);
ps.setString(6, filename);
ps.executeUpdate();
ps.close();
String sqlLockRow = "select document from documents where id = ? for update";
java.sql.PreparedStatement pst = con.prepareStatement(sqlLockRow);
pst.setInt(1, documentid);
java.sql.ResultSet rset = pst.executeQuery();
rset.next();
java.sql.Blob dbBlob = rset.getBlob(1);
out.println("it's=" + dbBlob.getClass());
OutputStream dbBlobOut = ((weblogic.jdbc.vendor.oracle.OracleThinBlob)dbBlob).getBinaryOutputStream();
dbBlobOut.write(oneString.getBytes());
dbBlobOut.close();
rset.close();
pst.close(); -
Hi,
I have some problems with blob mapping.
I map a Serializable field in a BLOB column (in MySQL 4.1 w/ latest Kodo
version) using following metadata:
<field name="metadata" persistence-modifier="persistent">
<extension vendor-name="kodo" key="type" value="Object"/>
<!-- extension vendor-name="kodo" key="jdbc-size" value="-1"/ -->
</field>
<field name="metadata">
<jdbc-field-map type="blob" column="METADATA"/>
</field>
Making the object persistent works well. The generated SQL is
INSERT INTO ATTRIBUTE_TYPE (METADATA, NAME, POID)
VALUES (?, ?, ?)
[params=(InputStream) java.io.ByteArrayInputStream@1c9b9ca, (String)
IntegerNew3, (long) 250] [reused=0]
Problems occur when I try to load the object. I get a ClassCastException
(see below). For information:
- I have saved the blob to my hard disk, and read it using
ObjectInputStream, and it works fine. So, the object is correctly stored.
- I have set the field in my Java class to java.lang.Object (instead of
my class implementing Serializable), and then it works fine too.
SELECT t0.POID, t0.NAME
FROM ATTRIBUTE_TYPE t0
WHERE (t0.NAME = ?)
[params=(String) IntegerNew3] [reused=0]
5578 TRACE [main] kodo.jdbc.SQL - <t 4219289, conn 4729123> [15 ms]
executing prepstmnt 2614099
SELECT t0.METADATA
FROM ATTRIBUTE_TYPE t0
WHERE t0.POID = ?
[params=(long) 250] [reused=0]
Exception in thread "main" kodo.util.GeneralException:
java.lang.ClassCastException: [B
at kodo.runtime.StateManagerImpl.loadFields(StateManagerImpl.java:3155)
at kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.java:3227)
at kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java:1368)
at
be.banksys.tams.model.base.AttributeType.jdoGetmetadata(AttributeType.java)
at
be.banksys.tams.model.base.AttributeType.getMetadata(AttributeType.java:50)
at be.banksys.tams.model.base.Essai.main(Essai.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
NestedThrowablesStackTrace:
java.lang.ClassCastException: [B
at
be.banksys.tams.model.base.AttributeType.jdoReplaceField(AttributeType.java)
at kodo.runtime.StateManagerImpl.replaceField(StateManagerImpl.java:3256)
at
kodo.runtime.StateManagerImpl.storeObjectField(StateManagerImpl.java:2640)
at kodo.runtime.StateManagerImpl.storeObject(StateManagerImpl.java:2624)
at kodo.jdbc.meta.BlobFieldMapping.load(BlobFieldMapping.java:231)
at
kodo.jdbc.runtime.JDBCStoreManager.loadMappings(JDBCStoreManager.java:1019)
at
kodo.jdbc.runtime.JDBCStoreManager.loadMappings(JDBCStoreManager.java:970)
at kodo.jdbc.runtime.JDBCStoreManager.load(JDBCStoreManager.java:510)
at
kodo.runtime.DelegatingStoreManager.load(DelegatingStoreManager.java:133)
at kodo.runtime.ROPStoreManager.load(ROPStoreManager.java:79)
at kodo.runtime.StateManagerImpl.loadFields(StateManagerImpl.java:3128)
at kodo.runtime.StateManagerImpl.loadField(StateManagerImpl.java:3227)
at kodo.runtime.StateManagerImpl.isLoaded(StateManagerImpl.java:1368)
at
be.banksys.tams.model.base.AttributeType.jdoGetmetadata(AttributeType.java)
at
be.banksys.tams.model.base.AttributeType.getMetadata(AttributeType.java:50)
at be.banksys.tams.model.base.Essai.main(Essai.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Regards,
J-FPatrick Linskey wrote:
Hi,
This is a known issue with MySQL, and Kodo 3.3.3 has a workaround for it
-- set the DBDictionary DriverDeserializesBlobs property to false:
kodo.jdbc.DBDictionary: DriverDeserializesBlobs=false
-PatrickDon't take it bad, but then why don't you put it in the MySQL known issues
in the documentation. It is a pity to waste hours on a known problem.
J-F -
Hello,
I hope you can help me :-) !!!!!!
I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
resultSet rs = ****query****
((oracle.jdbc.oracleSet) rs ).getBLOB(1);
but throws ClassCastException on the cast oracleSet......
i try withthis code:
ResultSet rs = ****query****
Blob b = rs.getBlob(1);
OutputStream out = b.setBinaryStream(1);
but throws java.sql.SQLException: Funzione non supportata
Why?????
what's can i do?
help me!!!!!!!
thanksHello,
I hope you can help me :-) !!!!!!
I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
resultSet rs = ****query****
((oracle.jdbc.oracleSet) rs ).getBLOB(1);
but throws ClassCastException on the cast oracleSet......
i try withthis code:
ResultSet rs = ****query****
Blob b = rs.getBlob(1);
OutputStream out = b.setBinaryStream(1);
but throws java.sql.SQLException: Funzione non supportata
Why?????
what's can i do?
help me!!!!!!!
thanks -
Updating Oracle BLOBs through Tomcat's DBCP
Hi, I've been using Tomcat's DBCP and I'm trying to cast my ResultSet to an OracleResultSet so I can use the getBLOB message. I've searched and realized I had to take part of it out of the wrapper, so I got the connection out of the wrapper using:
con = ds.getConnection().getMetaData().getConnection();which returned an OracleConnection. However, when I work through the rest of the code, it finally gets to:
BLOB filedata = ((OracleResultSet)oRS).getBLOB("filedata");and it dies with:
java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetImplIf I connect using JDBC without the DBCP datasource, this code works fine. I'm not sure why I can't cast it to something I can use. Can anyone provide some insight on this? I've searched and searched for solutions and tried so many things, but nothing has worked so far aside from just connecting using JDBC.
The ResultSet is not a DelegatingResultSet, which had tripped me up originally. Once I removed the wrapper from the connection, it seemed to give me all the correct types (OracleConnection, OracleStatement, & OracleResultSetImpl), but I can't seem to use the OracleResultSetImpl.
Here's my method:
public static int store(InputStream in) throws SQLException,IOException {
Connection con = null;
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/develop");
con = ds.getConnection().getMetaData().getConnection();
int id = 17;
String sql = "SELECT file_id,filedata FROM super_files WHERE file_id = "+id+" for update";
//sql = "SELECT file_id FROM super_files";
Statement stmt2 = con.createStatement();
System.out.println("stmt2 class: "+stmt2.getClass());
ResultSet oRS = stmt2.executeQuery(sql);
int key = 0;
if (oRS.next()) {
/* this next line is where it dies */
BLOB fileData = ((OracleResultSet)oRS).getBLOB("filedata");
int bufferSize = fileData.getBufferSize();
byte buffer[] = new byte[bufferSize];
OutputStream os = fileData.getBinaryOutputStream();
int bytesRead = 0;
while ((bytesRead = in.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
in.close();
os.close();
oRS.close();
stmt2.close();
con.commit();
return key;
}Hi, I am having the same problem. Were you able to resolve it? Please let me know. I have searched thru the entire WWW but coulnd't find the solution.
Maybe you are looking for
-
Occasionally it lights up (slowly, with a flash of bright light) to the apple screen, and then reverts to the wheel. I've tried pressing the home and power buttons for 20 seconds, which won't work. It does connect to iTunes, and I'm trying to restor
-
Paragraph stops word-wrapping in Firefox
I am having the toughest time with an iWeb '08 website and text formatting. In Safari, and IE, the page looks great. In Firefox 2.0.0.12 on both OSX and Windows XP, the paragraph text stops wrapping down the page. http://www.cleanupthemud.org/cutm/10
-
Spry vertical menu bar size issue
hello world, i've got a beautiful layout with a lefthand menu section that i would love to behave with pop-out menus. the entire design was crafted lovingly in fireworks and then exported as html with images, then opened in dreamweaver - looks great!
-
I installed Adobe Reader XI on my new computer running Windows 8. The file icons no longer show a thumbnail of the file, just the Reader logo. Any thoughts on how to fix this?
-
HT4702 Best web-sharing site for photos since Mobile Me Gallery is eliminated.
I shared many of my iPhoto albums with my friends and family through the Mobile Me Gallery. Now that that's gone, what do you recommend to replace this web-sharing of photos and videos?