You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by tonywestonuk <to...@totspics.com> on 2016/05/04 07:26:29 UTC
Access the underlying connection.
I need to get the underlying connection...so I can create Postgresql large
objects.
However, this doesn't work:
Connection rawConn = ((DelegatingConnection<Connection>)
con).getInnermostDelegate();
I get this error:
java.lang.ClassCastException: com.sun.proxy.$Proxy121 cannot be cast to
org.apache.tomcat.dbcp.dbcp2.DelegatingConnection
(I tried also with the other 2 DelegatingConnections in the class path with
the same results).
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Access-the-underlying-connection-tp4678338.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Access the underlying connection.
Posted by tonywestonuk <to...@totspics.com>.
Found it!! This will do what I need:
PGConnection postgresConnection=con.unwrap(PGConnection.class);
Your docs may need updating...
http://tomee.apache.org/datasource-config.html#accessToUnderlyingConnectionAllowed
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Access-the-underlying-connection-tp4678338p4678339.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Access the underlying connection.
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
Depend the config and datasource pool but here the things to check:
- access is allowed in the xml configuration (dbcp has a flag for instance)
- if proxied - can be for logging, jta... - ensure to unwrap it
(Proxy.getInvocationHandler(ds).getDelegate())
Le 4 mai 2016 08:00, "tonywestonuk" <to...@totspics.com> a écrit :
I need to get the underlying connection...so I can create Postgresql large
objects.
However, this doesn't work:
Connection rawConn = ((DelegatingConnection<Connection>)
con).getInnermostDelegate();
I get this error:
java.lang.ClassCastException: com.sun.proxy.$Proxy121 cannot be cast to
org.apache.tomcat.dbcp.dbcp2.DelegatingConnection
(I tried also with the other 2 DelegatingConnections in the class path with
the same results).
--
View this message in context:
http://tomee-openejb.979440.n4.nabble.com/Access-the-underlying-connection-tp4678338.html
Sent from the TomEE Users mailing list archive at Nabble.com.