Welcome to the JavaRanch, Anju!
Database connection pools are a standard feature in
J2EE application servers, including Tomcat.
You cannot share code between web applications. But the connection pool is easily obtainable from a simple JNDI lookup, so the amount of code that has to be duplicated between applications is small.
What actually makes the pool itself shareable between multiple web applications is where you define it.
For a pool used by only one application, you'd usually define the pool in that application's context xml file. To share a pool between multiple applications, you would have to configure the Tomcal server.xml file. I believe you can define shared. Connection pools at the Host and Engine levels.
You might also want to look at this:
http://tomcat.apache.org/tomcat-7.0-doc/config/globalresources.html
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.