File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes OracleConnection and Websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "OracleConnection and Websphere" Watch "OracleConnection and Websphere" New topic
Author

OracleConnection and Websphere

Anant Kabra
Greenhorn

Joined: Dec 10, 2003
Posts: 5
We are trying to use Websphere 5.0.1 with Oracle 9i as the database.
The problem is that when doing connection pooling through the application server, you get an object which is specific to the application server. We need to get an OracleConnection object. This is no problem under orion (oracle AS). With Weblogic, we are able to use the getVendorConnection to get the physical underlying object which returns the OracleConnection object, but with websphere there seems to be no way to do this...
I've tried a few different approaches as outlined below.
I would really appreciate any help. Thanks
We are trying to use oracle with websphere.
Websphere 5.0.1
Oracle JDBC driver classes12.zip from 9i release
We need to get an OracleConnection from the pool, and since the configured pool in websphere returns a websphere specific implementation class for the pooled connection, which cannot be cast to oracleconnection, we are stuck with implementing our own pool. I tried the following two methods with the described problems.
1. Using JNDI
We create an OracleConnectionCacheImpl object and put it in JNDI. To get a connection, a JNDI lookup on this object is done and the getConnection method is called.
This results in what seems like a new pool being created each time a JNDI lookup is done on the object. So each time we do a getConnection, a new connection to the database is opened. Obviously not what we want. This problem seems to be described in the oracle 8.1.6 documentation for OracleConnectionCacheImpl...

----------------------------------------------------------
Note:
OracleConnectionCacheImpl support for JNDI is not complete in release 8.1.6--an instance obtained through a lookup call does not have any connections opened; however, the connection properties, caching scheme, and limits for the number of pooled connections are retained.
----------------------------------------------------------
But there is no mention of this in the 9i documentation, so I thought the problem was fixed, but the issue we are encoutering looks very similar to this.
2. Singleton
So we implemented this using a singleton. The singleton instantiates an OracleConnectionCacheImpl object and returns this through a getter method. This object is used to getConnection. This seems to work at least as far as the pooling is concerned, but results in another problem. We are using the oracle jpub package, and we get a
java.sql.SQLException: Logical handle no longer valid
exception on some methods for mutablearrays or mutablestructs. This does not happen when using the JNDI implementation, or if getting a connection through drivermanager. The stack trace is attached below.
Please any help would be appreciated. Let me know if you need more info.
PS: With weblogic, there is a getVendorConnection method in the PooledConnection class implementation. This returns the underlying physical connection for the logical connection. Is there a similar method for websphere?
Thanks,
-- Anant
java.sql.SQLException: Logical handle no longer valid
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleConnection.checkPhyiscalStatus(OracleConnection.java:735)
at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConnection.java:792)
at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:748)
at oracle.jdbc.oracore.OracleTypeCOLLECTION.initCollElemTypeName(OracleTypeCOLLECTION.java:1016)
at oracle.jdbc.oracore.OracleTypeCOLLECTION.getAttributeType(OracleTypeCOLLECTION.java:1056)
at oracle.jdbc.oracore.OracleNamedType.getFullName(OracleNamedType.java:110)
at oracle.jdbc.oracore.OracleTypeADT.createStructDescriptor(OracleTypeADT.java:2262)
at oracle.jdbc.oracore.OracleTypeADT.unpickle81(OracleTypeADT.java:1638)
at oracle.jdbc.oracore.OracleTypeUPT.unpickle81UPT(OracleTypeUPT.java:462)
at oracle.jdbc.oracore.OracleTypeUPT.unpickle81rec(OracleTypeUPT.java:416)
at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81_imgBody_elems(OracleTypeCOLLECTION.java:957)
at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81_imgBody(OracleTypeCOLLECTION.java:923)
at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81(OracleTypeCOLLECTION.java:743)
at oracle.jdbc.oracore.OracleTypeCOLLECTION._unlinearize(OracleTypeCOLLECTION.java:242)
at oracle.jdbc.oracore.OracleTypeCOLLECTION.unlinearize(OracleTypeCOLLECTION.java:208)
at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:823)
at oracle.sql.ARRAY.getOracleArray(ARRAY.java:699)
at oracle.jpub.runtime.MutableArray.getLazyOracleArray(MutableArray.java:1067)
at oracle.jpub.runtime.MutableArray.length(MutableArray.java:1003)
at com.mycompany.presvc.predatasvc.MeasureListWrapDA.getArray(MeasureListWrapDA.java:73)
at com.mycompany.presvc.predatasvc.MetricDAO.convertToArg(MetricDAO.java:1245)
at com.mycompany.presvc.predatasvc.MetricGraphDAO.getFullGraph(MetricGraphDAO.java:298)
at com.mycompany.presvc.predatasvc.ejb.PreDataSvcEJB.getMetricGraph(PreDataSvcEJB.java:375)
at
.
<snip>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OracleConnection and Websphere