on 10-27-2005 11:18 AM
There is a known bug in the Oracle.sql.CLOB.createTemporary() class. The method signature is:
static CLOB createTemporary( java.sql.Connection conn, boolean cache, int duration )
Unfortunately, in the execution of this function a class cast is attempted on the "conn" argument to an OracleConnection. Any application running in an application server obtaining javax.sql.DataSources from a JNDI service will not have an instance of OracleConnection even though Oracle may be the underlying database. What is obtained is some kind of appserver-specific wrapper which delegates to an OracleConnection. This results in a ClassCastException, as can be seen in the following log excerpt:
2005-10-18 15:04:42,314 DEBUG [SAPEngine_Application_Thread[impl:3]_28] (ProductionIDHandler.java:31) - handleRequest()
2005-10-18 15:04:42,333 FATAL [SAPEngine_Application_Thread[impl:3]_28]
(LSCDBrokerBean.java:205) -
java.lang.ClassCastException
at oracle.sql.CLOB.createTemporary(CLOB.java:683)
at oracle.sql.CLOB.createTemporary(CLOB.java:650)
at com.philips.lscd.utils.OracleUtils.makeClob(OracleUtils.java:20)
at
com.philips.lscd.pr.ProductionIDHandler.handleRequest(ProductionIDHandler.java:36)
at com.philips.lscd.broker.LSCDBrokerBean.brokerRequest(LSCDBrokerBean.java:181)
at
com.philips.lscd.broker.LSCDBrokerBean.doGetProductionID(LSCDBrokerBean.java:144)
at
com.philips.lscd.broker.LSCDBrokerLocalLocalObjectImpl0.doGetProductionID(LSCDBrokerLocalLocalObjectImpl0.java:247)
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:324)
The available solutions range from avoiding use of the Clob type, setting a
certain property in the data source that would cause Oracle to automatically
treat strings greater than 32K as Clobs, or somehow obtaining the
OracleConnection from the wrapper object and passing that to
createTemporary(). The first solution is not an option as we cannot rule out
handling XML documents greater than 32K; the second solution has undesirable
side effects; this last option is the best even though it is an
appserver-specific solution.
The wrapper object which we obtain from the DataSource which is obtained from
the SAP application server is of type:
com.sap.engine.services.dbpool.cci.ConnectionHandle
Can anyone either indicate a public method available on this object by which we may obtain the underlying OracleConnection or suggest another solution?
How we solved this problem is that when we wish to insert or update a row containing a clob, we check if we are running in the context of an application server and, if so, we execute a query that returns a clob as an out parameter.
Without executing a commit, we fill this clob and then use it as an input parameter to the stored procedure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Johan,
you are right: in the context of a j2ee server (datasources obtained from the JNDI service) you always get a wrapper of an Oracle connection. This is necessary as the server needs an access to transactions events for example. In other words you cannot invoke Oracle-specific methods if you look up the datasource via JNDI.
To help you, we need a little bit more information. Could you please write short
- why you need to call the createTemporary method?
- have you checked if you could solve your task using Open SQL (JDBC 2.1). By the way, on the Native SQL layer, SAP's wrapper is correcting some well know Oracle driver bugs in the area of LOB processing.
regards, Katharina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.