File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Constant Connection Pooling inside Jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Constant Connection Pooling inside Jar?" Watch "Constant Connection Pooling inside Jar?" New topic
Author

Constant Connection Pooling inside Jar?

Caden Whitaker
Greenhorn

Joined: Jan 15, 2009
Posts: 24
The goal of one project is to create a single jar that contains all of our data objects and sql commands for our 3 different databases and 4 webservice connections. This is going to be used in several applications - many of them rely on pieces of all three databases and some of the webservices. Our goal is to reduce all of this down to method calls where they just rely on the objects being returned. That way if we (finally) consolidate this data we just distribute a new jar to the applications and (hopefully) encounter no issues.

The big question for me is connection pooling. I don't want them to know anything about the databases they'll be connecting to, I want that all included in the jar. I don't want them to have to set up connection sources in tomcat, I'd like that all done in the jar. But can I set up some sort of persistent connection pool? Some applications have hundreds of users hitting them every few seconds while other applications have perhaps a dozen users per day. In the situations where it is only a handful of users it would be nice to have a connection pool ready so they do not encounter a delay getting a database connection.

I looked at some basic stuff

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html

But I'm not sure if it is possible to set up some sort of jar-aware persistence without SOME reference from the underlying application. Am I correct? Any suggestions on what I could do?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Please check if the license agreement of the software packages (pools, db drivers, ...) allows you to re-package or unjar/rejar their libraries.


OCUP UML fundamental and ITIL foundation
youtube channel
Caden Whitaker
Greenhorn

Joined: Jan 15, 2009
Posts: 24
Thanks for the tip, I'll be careful... but I don't even have anything to go off this moment I'm looking for suggestions, and a good conn pooling jar friendly project would be a nice start
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Tomcat already has perfectly good connection pooling. What was your reason for rejecting it?
Caden Whitaker
Greenhorn

Joined: Jan 15, 2009
Posts: 24
Tomcat already has perfectly good connection pooling. What was your reason for rejecting it?


This may sound petty but I didn't want to have to manually keep track of the database information inside each instance of tomcat we have running.

Each instance of tomcat on our developer machines, development, pre-production, the production boxes. In my opinion that's a lot of room for error. Especially since we have multiple projects that shouldn't have to know where the data is coming from, they just need a simple way to access that data. I'd rather have all the DB info in a properties file inside the jar rather then having to put it on everyone's machine (and when we make changes to the db we have to replicate those changes).

The big reason for this is we are expecting a lot (A LOT) of data changes over the next couple of months. The entire removal of one database, the integration of two others, combinations, refactorings and the like are going to be a common issue for us. And I'd hate to have to tell the IT dept to make manual changes to reflect this.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You can also just place the context.xml with datasource settings in the META-INF of your webapp and Tomcat will pick it up.
Also see http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constant Connection Pooling inside Jar?
 
Similar Threads
JMS newbie - security question
Could not get a good connection to the database ?
is jdbc connection deadly for application servers ?
issue related to JTable and SQLite database
Please justify about EJB