getConnection from PoolConnection

I get ClassCastException:
//------------------------------------------- TConnection connection = tConnectionPool.getConnection();
if(connection == null) {
System.out.println(“connection = null”);
System.out.println(“debag = after connection”);

TXMLObjectAccessor xmlObjectAccessor =
(connection).newXMLObjectAccessor(TAccessLocation.newInstance( “sailing” ),TJDOMObjectModel.getInstance() );

System.out.println(“debag = after accessor”);

Exception in thread “main” java.lang.ClassCastException: com.softwareag.tamino/db.api.accessor.TXMLObjectAccessorImpl
at com.softwareag.tamino.db.api.connection.TConnectionWrapper.newXMLObjectAccessor(
at TestPool.main(

I can not do:
((TConnectionWrapper) connection).newXMLObjectAccessor(…
because TConnectionWrapper is not public class.

What is wrong?
Please hellp me.

I’m not sure we’re using the same version of the API, but this code works for me with Version of the API.


TConnection myConnection = null;
TConnectionPoolManager myPoolManager = TConnectionPoolManager.getInstance();
if (myPoolManager.hasPool(“POOL_NAME”)) {
myConnection = myPoolManager.getConnection(“POOL_NAME”);
else {
System.out.println(“Connection Pool POOL_NAME is not defined - check ManagedConnectionPools.xml”);

You need to define a connection pool in a file called “ManagedConnectionPools.xml” and this must be available in classpath. The contents look like this:



I use version
I have not problem with get connection,
it throw ClassCastException when is createed XMLObjectAccessor.

System.out.println(“debag = after connection”);
TXMLObjectAccessor xmlObjectAccessor =
connection.newXMLObjectAccessor(TAccessLocation.newInstance( “sailing” ),TJDOMObjectModel.getInstance() );

System.out.println(“debag = after accessor”);

Some problem is in class TConnectionWrapper.
Method newXMLObjectAccessor create TXMLObjectAccessor instance but then propabli
cast txmlobjectaccessor to another class or inerface.(throw ClassCastException)

My thinking was that if your TConnection is not initialized correctly (for whatever reason) then when you invoke its “newXMLObjectAccessor()” method you might get a problem. In your first code snippet you wrote:


TConnection connection = tConnectionPool.getConnection();

but in the new API Documentation I don’t see this as a documented way of creating a TConnection object (getConnection() is a method of TConnectionPoolManager and takes a String argument).
I can continue my example code like this:

(follows on from creating myConnection…)
// Build an XMLObjectAccessor
TXMLObjectAccessor xmlObjectAccessor = myConnection.newXMLObjectAccessor(TAccessLocation.newInstance( DATABASE_COLLECTION ),
TJDOMObjectModel.getInstance() );
System.out.println(“debug = after accessor”);

and this works. Sorry if it doesn’t help you.
Maybe you could post your complete source code?

[This message was edited by Bill Leeney on 29 Nov 2001 at 15:25.]