• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get underlying connection

 
nick alex
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using DBCP for connection pooling and want to access the underlying connection(Physical connection).
Also how can I configure my context.xml for same
Any body there to help..


Cheers niCk
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've added the DBCP libraries to your webapp or do you mean that you're using container managed connection pooling provided by Tomcat?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the documentation. I'm sure there is a setting that allows access to the actual connection rather than the wrapper.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DBCP and Tomcat instructions are here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

DBCP says you need to set the 'accessToUnderlyingConnectionAllowed' to true, sample code is provided.
http://commons.apache.org/dbcp/configuration.html
 
nick alex
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,
I was using container managed connection pooling provided by Tomcat.
I switched to commons DBCP
As suggested by David
Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
works..
Thanks Ben and David.

--Nick
[ May 02, 2008: Message edited by: nick alex ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a note:
Tomcat uses DBCP as its connection pool library.
You might not need to bring it in yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic