There is an discussion about the same at Sun. http://forum.java.sun.com/thread.jsp?thread=386190&forum=48&message=1660462
I would use a datasource or pool to ensure a flow in the application unless you're very sure, that your connection implementation allows concurrent statements to be executed and not just executes them one at a time. The link above reads : >>For example, two Statements on the same Connection can be executed >>concurrently and their ResultSets can be processed concurrently (from the >>perspective of the developer). Some drivers will provide this full >>concurrency. Others may execute one statement and wait until it completes before >>sending the next. Maby you should look at Jarkata' pool or look at some datasources. Few connections are good because fewer connections uses less memory and less cpu and therefore allows faster executions. But fewer connections also, depending on the complexity of the requests and size of the results, makes "faster waits" for those threads not in possession of a connection :@) Regards Kleth ------------------------------------------------------------------------------------------ Kristian A. Leth Maersk Data Transport/Architects & Specialists. ------------------------------------------------------------------------------------------ Hans Wichman <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] cc: 05-08-2003 21:29 Subject: database connection Please respond to "Tomcat Users List" Hi, I am evaluating a jsp application for a customer, which provides an interface to a database through some helperclasses. Each helper class manages the retrieval (and updates) of related underlying tables, and there are about 10 helperclasses. In the header (header.jsp) the jsp calls an initialize method on a Configuration object, checks if it is already initialized (this process is not synchronized), and if not, creates one connection, creates all the 10 helper classes as static instances passing this one-and-only connection. In the rest of the application a collection of tags call the static methods (unsynchronized) on the Configuration object, such as getDatabaseHelper1 (be it with a more descriptive name) and performs operations on the underlying database through this class. All the methods in the Helper classes are unsynchronized as well, but they are standalone (utility functions, I don't know a better way to describe it). My question is, except from any race conditions in the helper classes themselves, is it a problem that all those helper classes share only one connection and access it unsynchronized. If so, why is it a problem if unsynchronized communication occurs on a database connection? Or are all the underlying methods on the connection object already synchronized and is there no need to worry? Some pointers to why and how would be appreciated as well. And I am not only looking to why connection pooling would be good, but also why one connection would be bad ;-) kind regards Hans --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]