dcsimg
Why does the Sun's bookstore1 example restrict access to the connection to a single thread, but bookstore2 does not?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Julian_Rockey
Posted On:   Saturday, March 13, 2004 04:31 AM

I'm trying to understand the best practice for handling database connections in Servlet/JSP based applications. In Sun's examples, the bookstore1 example creates a BookDB object which is placed in the context when the context is created. It holds a single connection to the database, and database calls are handled by BookDB, and ensures the connection is used by 1 thread at a time by writing a getConnection() and a releaseConnection() method. However, bookstore2 splits BookDB into BookDB and BookDBAO, and dispenses with the getConnection() an releaseConnection() thing. BookDBAO is still created in the context, so 1 per webapp - I just can't figure out why the connection can suddenly be 'shared'. I've searched many a forum before asking here and can't find th   More>>

I'm trying to understand the best practice for handling database connections in Servlet/JSP based applications. In Sun's examples, the bookstore1 example creates a BookDB object which is placed in the context when the context is created. It holds a single connection to the database, and database calls are handled by BookDB, and ensures the connection is used by 1 thread at a time by writing a getConnection() and a releaseConnection() method.
However, bookstore2 splits BookDB into BookDB and BookDBAO, and dispenses with the getConnection() an releaseConnection() thing. BookDBAO is still created in the context, so 1 per webapp - I just can't figure out why the connection can suddenly be 'shared'. I've searched many a forum before asking here and can't find the answer - can anyone enlighten me on this? Much appreciated!

   <<Less
About | Sitemap | Contact