Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Streaming Blob or calling SQLXML directly for certain fields

Here is another little tidbit of info:

 

When I used the XMLDataCustomizer example with a commons-pool connection in Tomcat, I got this:

 

javax.persistence.RollbackException: java.lang.ClassCastException: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.j

on

        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)

        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)

        at oracle.documaker.jpa.Main.main(Main.java:96)

Caused by: java.lang.ClassCastException: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection

        at oracle.sql.OpaqueDescriptor.createDescriptor(OpaqueDescriptor.java:184)

        at oracle.xdb.XMLType.<init>(XMLType.java:540)

        at oracle.xdb.XMLType.createXML(XMLType.java:635)

        at org.eclipse.persistence.internal.platform.database.oracle.xdb.XMLTypeBindCallCustomParameter.set(XMLTypeBindCallCustomParameter.java:40)

        at org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:2184)

        at org.eclipse.persistence.platform.database.oracle.Oracle9Platform.setParameterValueInDatabaseCall(Oracle9Platform.java:474)

        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.prepareBatchStatements(ParameterizedSQLBatchWritingMechanism.java

        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.ja

        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.writesCompleted(DatabaseAccessor.java:1707)

        ! at org.eclipse.persistence.internal.sessions.AbstractSession.writesCompleted(AbstractSession.java:3845)

        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.writesCompleted(UnitOfWorkImpl.java:5522)

        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.acquireWriteLocks(UnitOfWorkImpl.java:1620)

        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitTransactionAfterWriteChanges(UnitOfWorkImpl.java:1588)

        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:275)

        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1143)

        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)

        ... 2 more

 

It is my experience that containers wrap the OracleConnection object  with their own wrapper classes for connection pooling purposes.

 

What I had to do in the past (when using straight JDBC) was to use reflection and get the underlying connection object from the wrapper class for each container before creating an XMLType object.  However, the latest ojdbc6.jar file supports SQLXML also. Under the covers it still uses xdb.jar and requires xmlparserv2.jar but the nice thing about the latest version is that you can just use SQLXML in your code instead of having to explicitly create an XMLType object.

 

Based on the error above, how would I use the XMLDataCustomizer example in any container?

 

Also, it is my expe! rience that xmlparserv2.jar file cannot be included in WebSphere or in JBOSS as when I tried it the class loaders for the containers complained about xml parsing classes – basically, including xmlparserv2.jar file caused the container to load xml parsing classes from that JAR file instead of its own xml parsing classes and started causing errors.  What I had to do to get around this problem is strip everything from xmlparserv2.jar file that xdb.jar file didn’t need and place it into a new Jar file and deploy it in WAS and JBOSS.  That is the only way I could get around this problem and support XMLType for the oracle database

 

Anyway,  if anyone can tell me how to extend or implement something (hopefully there are some examples) so I can make direct JDBC calls for XML or BLOB columns that would be great.

 

From: Carl Roberts
Sent: Wednesday, August 31, 2011 6:36 PM
To: eclipselink-users@xxxxxxxxxxx
Subject: Streaming Blob or calling SQLXML directly for certain fields

 

Hi guys,

 

Is there a way to extend some classes or implement some interfaces in EclipseLink to make direct JDBC calls for certain table columns so that I can do streaming of BLOB data or use the SQLXML class for XML columns?

 

I have already gone through the XMLDataCustomizer example and I just want to point out that this is not an accepatable solution for me as it assumes I am using an OracleConnection object and that I am dealing with an Oracle database.

 

I would like to use the SQLXML class instead and direct JDBC calls when dealing with XML columns in DB2, MSSQL and Oracle.

 

If anyone has done this or has some suggestions I would really appreciate it.  Also, I briefly looked at this link:

 

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Converters

 

But I am not sure if I can use a Converter class - it seems converters are really there to massage data after retrieving it and before inserting it but what I want to do is make direct JDBC calls to the database for XML columns and perhaps Blobs as well.


Thanks,

 

Joe


Back to the top