We've had nothing but headaches using the Oracle JDBC drivers. They don't
handle LOBs the way everyone else does, especially when the size is greater
than 4000. That's a specific cuttoff. Anything below that will behave the
way you'd expect. Anything over that will certainly fail unless you code
specifically to handle it (at least in our testing).

Here are a couple articles that may be useful:

    http://otn.oracle.com/doc/java.815/a64685/oraext4.htm#1043351

http://technet.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc20/LOBSa
mple/LOBSample.java.html

Hope this is helpful.

Brian

----- Original Message -----
From: "Dain Sundstrom" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 18, 2002 11:04 AM
Subject: Re: [JBoss-dev] Oracle BLOB handling - FIXED?


> This is the way the code was before I integrated the Oracle BLOB patch.
> The problem is the serialized stream is being truncated to 4000 bytes.
>
> I just got an email from someone willing to work on implementing correct
> BLOB handling.
>
> I'd still like someone to try this in Oracle 8.
>
> -dain
>
> Stephen Coy wrote:
> > I've done some more  poking at this, and modified JDBCUtil.setParameter
> > as follows:
> >
> >       //
> >       // Binary types need to be converted to a byte array and set
> >       //
> >       if(isBinaryJDBCType(jdbcType))
> >       {
> >          byte[] bytes = convertObjectToByteArray(value);
> >
> >          if (bytes.length < 2000 && jdbcType != Types.BLOB)
> >          {
> >             // it's more efficient to use setBinaryStream for large
> >             // streams, and causes problems if not done on some DBMS
> >             // implementations
> >             ps.setBytes(index, bytes);
> >          } else
> >          {
> >             InputStream in = null;
> >             try
> >             {
> >                in = new ByteArrayInputStream(bytes);
> >                ps.setBinaryStream(index, in, bytes.length);
> >             } finally
> >             {
> >                safeClose(in);
> >             }
> >          }
> >          return;
> >
> > ie. Forget about the ByteArrayBlob class.
> >
> > This works fine when writing to the database.
> >
> > However, reading the data back fails:
> >
> > 2002-06-18 23:59:20,671 DEBUG
> > [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.SimpleEJB]
> > Executing SQL: SELECT booleanPrimitive, booleanObject, bytePrimitive,
> > byteObject, shortPrimitive, shortObject, integerPrimitive,
> > integerObject, longPrimitive, longObject, floatPrimitive, floatObject,
> > doublePrimitive, doubleObject, stringValue, utilDateValue, sqlDateValue,
> > timeValue, timestampValue, bigDecimalValue, byteArrayValue, objectValue
> > FROM SIMPLE WHERE (id=?)
> > 2002-06-18 23:59:20,680 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.id]
> > Set parameter: index=1, jdbcType=VARCHAR, value=simple
> > 2002-06-18 23:59:20,707 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.boolea
nPrimitive]
> >
> >  Get result: index=1, javaType=boolean, Simple, value=true
> > 2002-06-18 23:59:20,709 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.boolea
nObject]
> >
> >  Get result: index=2, javaType=java.lang.Boolean, Simple, value=false
> > 2002-06-18 23:59:20,713 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.bytePr
imitive]
> >
> >  Get result: index=3, javaType=byte, Simple, value=11
> > 2002-06-18 23:59:20,715 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.byteOb
ject]
> >
> >  Get result: index=4, javaType=java.lang.Byte, Simple, value=22
> > 2002-06-18 23:59:20,717 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.shortP
rimitive]
> >
> >  Get result: index=5, javaType=short, Simple, value=33
> > 2002-06-18 23:59:20,718 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.shortO
bject]
> >
> >  Get result: index=6, javaType=java.lang.Short, Simple, value=44
> > 2002-06-18 23:59:20,720 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.intege
rPrimitive]
> >
> >  Get result: index=7, javaType=int, Simple, value=55
> > 2002-06-18 23:59:20,726 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.intege
rObject]
> >
> >  Get result: index=8, javaType=java.lang.Integer, Simple, value=66
> > 2002-06-18 23:59:20,728 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.longPr
imitive]
> >
> >  Get result: index=9, javaType=long, Simple, value=77
> > 2002-06-18 23:59:20,730 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.longOb
ject]
> >
> >  Get result: index=10, javaType=java.lang.Long, Simple, value=88
> > 2002-06-18 23:59:20,731 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.floatP
rimitive]
> >
> >  Get result: index=11, javaType=float, Simple, value=11.11
> > 2002-06-18 23:59:20,733 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.floatO
bject]
> >
> >  Get result: index=12, javaType=java.lang.Float, Simple, value=22.22
> > 2002-06-18 23:59:20,735 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.double
Primitive]
> >
> >  Get result: index=13, javaType=double, Simple, value=33.33
> > 2002-06-18 23:59:20,738 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.double
Object]
> >
> >  Get result: index=14, javaType=java.lang.Double, Simple, value=44.44
> > 2002-06-18 23:59:20,740 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.string
Value]
> >
> >  Get result: index=15, javaType=java.lang.String, Simple, value=test
> > string value
> > 2002-06-18 23:59:20,742 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.utilDa
teValue]
> >
> >  Get result: index=16, javaType=java.util.Date, Simple, value=1970-01-01
> > 11:00:01.111
> > 2002-06-18 23:59:20,744 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.sqlDat
eValue]
> >
> >  Get result: index=17, javaType=java.sql.Date, Simple, value=1981-05-05
> > 2002-06-18 23:59:20,746 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.timeVa
lue]
> >
> >  Get result: index=18, javaType=java.sql.Time, Simple, value=22:33:44
> > 2002-06-18 23:59:20,748 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.timest
ampValue]
> >
> >  Get result: index=19, javaType=java.sql.Timestamp, Simple,
> > value=1970-01-01 11:00:04.444
> > 2002-06-18 23:59:20,749 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.bigDec
imalValue]
> >
> >  Get result: index=20, javaType=java.math.BigDecimal, Simple,
> > value=12345678
> > 2002-06-18 23:59:20,751 TRACE
> >
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.SimpleEJB.byteAr
rayValue]
> >
> >  Get result: index=21, javaType=[B, Simple, value=[B@2b8a17
> > 2002-06-18 23:59:20,758 TRACE
> > [org.jboss.ejb.plugins.EntitySynchronizationInterceptor] loadEntity
> > Exception, clear tx for
> > ctx=org.jboss.ejb.EntityEnterpriseContext@74683e,
> > tx=TransactionImpl:XidImpl [FormatId=257,
> > GlobalId=edoras.resolvesw.com.au//40, BranchQual=]
> > 2002-06-18 23:59:20,760 TRACE
> > [org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy] entryRemoved,
> > entry=key: null, object: null, entry: 67e62c
> > 2002-06-18 23:59:20,762 TRACE
> > [org.jboss.ejb.plugins.EntityInstanceInterceptor] Ending invoke,
> > exceptionThrown, ctx=org.jboss.ejb.EntityEnterpriseContext@74683e
> > 2002-06-18 23:59:20,764 TRACE
> > [org.jboss.ejb.plugins.EntityInstanceInterceptor] End invoke,
> > key=simple, ctx=org.jboss.ejb.EntityEnterpriseContext@74683e
> > 2002-06-18 23:59:20,765 TRACE
> > [org.jboss.ejb.plugins.EntityLockInterceptor] End invoke, key=simple
> > 2002-06-18 23:59:20,766 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > TxInterceptorCMT: In finally
> > 2002-06-18 23:59:20,770 ERROR [org.jboss.ejb.plugins.LogInterceptor]
> > TransactionRolledbackException, causedBy:
> > java.sql.SQLException: Unable to load to deserialize result:
> > java.io.StreamCorruptedException: InputStream does not contain a
> > serialized object
> >     at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertByteArrayToObject
> > (JDBCUtil.java:599)
> >     at
org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.getResult(JDBCUtil.java:306)
> >     at
> >
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumen
tResults(
> >
> > JDBCAbstractCMPFieldBridge.java:350)
> >     at
> >
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadInstanc
eResults(
> >
> > JDBCAbstractCMPFieldBridge.java:304)
> >     at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute
> > (JDBCLoadEntityCommand.java:142)
> >     at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute
> > (JDBCLoadEntityCommand.java:62)
> >     at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity
> > (JDBCStoreManager.java:569)
> >     at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity
> > (CMPPersistenceManager.java:410)
> >     at
> >
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(
> >
> > CachedConnectionInterceptor.java:353)
> >     at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke
> > (EntitySynchronizationInterceptor.java:262)
> >     at
> > org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke
> > (CachedConnectionInterceptor.java:186)
> >     at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke
> > (EntityInstanceInterceptor.java:152)
> >     at
> >
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.jav
a:
> >
> > 107)
> >     at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke
> > (EntityCreationInterceptor.java:69)
> >     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
> > (AbstractTxInterceptor.java:96)
> >     at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions
> > (TxInterceptorCMT.java:176)
> >     at
> > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
> >     at
> >
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:
> > 129)
> >     at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:183)
> >     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke
> > (ProxyFactoryFinderInterceptor.java:156)
> >     at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:482)
> >     at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke
> > (BaseLocalProxyFactory.java:304)
> >     at
org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
> >     at $Proxy41.getBooleanPrimitive(Unknown Source)
> >     at
org.jboss.test.cmp2.simple.SimpleUnitTestCase.testBooleanPrimitive
> > (SimpleUnitTestCase.java:90)
> >     at java.lang.reflect.Method.invoke(Native Method)
> >     at junit.framework.TestCase.runTest(TestCase.java:166)
> >     at junit.framework.TestCase.runBare(TestCase.java:140)
> >     at
net.sourceforge.junitejb.EJBTestCase.runBare(EJBTestCase.java:133)
> >     at
> >
net.sourceforge.junitejb.EJBTestRunnerBean.runTestCase(EJBTestRunnerBean.jav
a:
> >
> > 102)
> >     at
> >
net.sourceforge.junitejb.EJBTestRunnerBean.run(EJBTestRunnerBean.java:44)
> >     at java.lang.reflect.Method.invoke(Native Method)
> >     at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke
> > (StatelessSessionContainer.java:606)
> >     at
> > org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke
> > (CachedConnectionInterceptor.java:186)
> >     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
> > (AbstractTxInterceptor.java:96)
> >     at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext
> > (AbstractTxInterceptorBMT.java:144)
> >     at
> > org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
> >     at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke
> > (StatelessSessionInstanceInterceptor.java:77)
> >     at
> >
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:
> > 129)
> >     at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:183)
> >     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke
> > (ProxyFactoryFinderInterceptor.java:156)
> >     at
> >
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.jav
a:
> >
> > 303)
> >     at org.jboss.ejb.Container.invoke(Container.java:687)
> >     at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
> >     at
> >
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:321)
> >     at java.lang.reflect.Method.invoke(Native Method)
> >     at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
> >     at sun.rmi.transport.Transport$1.run(Transport.java:152)
> >     at java.security.AccessController.doPrivileged(Native Method)
> >     at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
> >     at
> > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
> >     at
> >
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:
> > 706)
> >     at java.lang.Thread.run(Thread.java:496)
> > 2002-06-18 23:59:20,789 TRACE [org.jboss.ejb.plugins.LogInterceptor] End
> > method=getBooleanPrimitive
> >
> > This seems to indicate that the BLOB was reloaded correctly, but the
> > OBJECT column was fubar.
> >
> > A possible cause of this is that I don't think that you can use
> > ResultSet.getBytes to recover the data from a BLOB that was written with
> > PreparedStatement.setBinaryStream.
> >
> > Unfortunately, it will be another day before I can pursue this further.
> >
> >
> >
> > On Sunday, June 16, 2002, at 03:28  PM, Dain Sundstrom wrote:
> >
> >> I just committed the code from patch [ 525663 ] CMP and oracle blobs.
> >> Can some with Oracle check if the code actually works?
> >>
> >> The following command will execute a new test I added which has a
> >> field of every type:
> >>
> >> ./build.sh -Dtest=org.jboss.test.cmp2.simple.SimpleUnitTestCase
one-test
> >>
> >> You'll need to change the datasource and datasource-mapping in the
> >> src/resources/cmp2/simple/META-INF/jbosscmp-jdbc.xml file.
> >>
> >> This won't work perfectly for every database vendor, because some
> >> vendor's don't support millisecond precise time and nanosecond precise
> >> timestamp values.  The test that is important for blobs is
> >> testObjectValue.
> >
> >
> >
>
> --------------------------------------------------------------------------
--
> >
> >                   Bringing you mounds of caffeinated joy
> >                      >>>     http://thinkgeek.com/sf    <<<
> >
> > _______________________________________________
> > Jboss-development mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jboss-development
>
>
> --
> xxxxxxxxxxxxxxxxxxxxxxxx
> Dain Sundstrom
> Chief Architect JBossCMP
> JBoss Group, LLC
> xxxxxxxxxxxxxxxxxxxxxxxx
>
>
> --------------------------------------------------------------------------
--
>                    Bringing you mounds of caffeinated joy
>                       >>>     http://thinkgeek.com/sf    <<<
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development


----------------------------------------------------------------------------
                   Bringing you mounds of caffeinated joy
                      >>>     http://thinkgeek.com/sf    <<<

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to