Search code examples
javarestconnection-poolingrestlet

How to use JDBC Connection Pool in Restlet Java Webservice?


Hi All I am using REST framework to devlope webservice in Java through restlet API. I am using Tomcat 6.0.35 as web container.

I want to use Database Connection Pool for JDBC connection in my project. I came to know about BoneCP is good one, so I want to try it.

I have 20 webservices in one project i.e. one Resource class for one webservice. And there is single Application class that routes each web service by clients request.

Right now I am opening and closing the JDBC Connection in every webservice.

So my question is, How can I use one JDBC connection for all webservices? In which class I have to open and close the JDBC connection?

Please help me. Thanks in Advance.


Solution

  • I would suggest you use Hibernate with C3P0 connection pooling , its best , it directly gives you sessions and you dont have to worry about closing the connection etc.