views:

101

answers:

2

I'm using WASCE as application server and defined a data source to PosgreSQL. I get the DB Connection from JNDI.

The problem is I want to access specific method in the PostgreSQL java.sql.Connection but WASCE wrapped this connection with their own Connection.

Specifically, I want to do something like this:

((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");

Is that possible? If yes, please share how.

EDIT:

I expect to have something like access to the original Connection from this wrapped Connection, but I can't find any until now.

+3  A: 

Generally connections will be handled through a pool. In order to be handled (relatively) transparently you will get a proxy to the real connection. Therefore, you cannot successfully cast the connection directly. The connection pool may have an API that allows you to get to the underlying connection.

Tom Hawtin - tackline
Yes... I expect to have something like that, but I can't find any until now.
nanda
+2  A: 

You can try

((PooledConnection) conn).getConnection()

Or, since Java 1.6:

conn.unwrap(...)
axtavt