Thanks - all of the DAO classes are static. I don't think that is the immediate problem. I'm having a concurrent list modification that occurs on a single record. Since there are no nested select statement in MySQL, I'm having to use a lot of list and select statements. It really sucks.....I just have to track down the bug and re-evaluate some other things. Quickly....:) ----- Original Message ----- From: "V. Cekvenich" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, September 29, 2002 8:49 PM Subject: JDBC Connection pool sample code; was Re: Best practices for Tomcat and server load
> A FAQ is what is good practice for JDBC connection pooling and how to > use it with Java Beans. > > My Ans, with working source code: > > (A good practices is: a property that has a getter/setter in a bean, and > a bean has a DAO it delegates to.) > > You could have a DAO with a class/static initialize that gets the data > source/connection pool > I do not like philosophical answers so here is a code sample, note use > of static, hence done once to get a handle on the data source/connection > pool: > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicPortal_07/sr c/org/commons/DAO/BasicDAOImpl.java?rev=1.1.1.1&content-type=text/vnd.viewcv s-markup > > It uses DBCP from Jakarta commons connection pool, but you get the point > of how to use a static class initialize to get a handle to a data source > so you can look up the data source once, and then just dish out connection. > > Also I use rowset over resultset, which makes it very easy to close, and > destroy, unlike resultset. (con.close,rs.close, stmnt.close in finaly, > plus it loses data on a connection disconect) > Rowset also does reduces need for GC generated by VO/DTO and > collections, since a disconnected rowset has the values. I use an open > source rowset from sourceforge called jxutil. > > hth, > V. > > ps: Consider doing MVC, hence each layer is unit testable, such as a > bean that delegates to DAO interface, which above also enables, as well > as enabling you to change the implemenentation of the DAO. > > ps2: Answer to what is the most popular hands on training class and who > teaches it? > http://www.mail-archive.com/mvc-programmers%40basebeans.com/msg00242.html > > Also, at basicPortal.sf.net you can download for free a 350 page book a > bit more advanced that talks about db quite a bit. > > > > Bill Blackmon wrote: > > I'm getting complaints from my host about excessive CPU usage in my web app. > > I'm unable to use > > connection pooling in the servers environment so I'm using a new connection > > for each DB call (and > > there are quite a few). The connections are promptly closed afterwards. Is > > it a better idea to use a > > connection for each session and check to see if its still valid each time it > > is needed? There are many lookup lists > > maintained in sessions as ArrayLists. Should those be made > > application-level? I also have a number of static > > factory classes that perform database/business logic. Should those be made > > into Singletons? What is a good monitoring tool > > for development on Win2000? The server is Linux but I have no way of seeing > > how big the load is....any help > > would be greatly appreciated. > > > > Thanks, > > Bill > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
