Whats about a thread local variable to store the connection instead of as instance variable ?
On 8/24/05, Gareth Evans <[EMAIL PROTECTED]> wrote: > Hi Paul, > > How about using a DBCP, that way the connections are always there, a getting > a connection each time > you need to do a unit of work becomes less of an overhead. With dbcp you can > create your connection > by using an xml file usually named 'something.jocl', drop this into you > classpath and load a > connection like you normally would, the url for the connection being > 'jdbc:apache:commons:dbcp:/something' > > Take a look at the jocl example > > http://cvs.apache.org/viewcvs/jakarta-commons/dbcp/doc/ > > This allows an easy to create, easy to change database configuration, using a > connection pool. > > Regards, > > Gareth > > Paul Benedict wrote: > > Guys, > > > > This is off-topic but I need your help. There are some > > good programmers here and I would like to receive some > > advice back. I am sure there's a simple answer to it. > > > > My Struts app is a multitier app (Web -> Business -> > > DAO) and it uses Jakarta Commons DbUtils for the DAO > > layer. My DAO methods are the typical get > > connection,execute,close connection pattern. Well, > > suddenly my DAO methods are complex enough that I can > > call my publically defined methods as helpers, which > > leads to all sorts of problems. That would opening a > > connection per call to a sibling method! > > > > What should be done here? > > > > I thought of moving the ownership of the connection > > from the method to the instance level. Is this > > appropriate? At least I could get sharing of a > > connection. But some business layers call multiple > > different DAO objects and it makes even more sense to > > share a connection across all DAO objects. Would this > > be better? I think so, but I don't know how to model > > it. > > > > Please, any help! It is holding up my design. > > > > Thanks, > > Paul > > > > > > > > __________________________________ > > Yahoo! Mail > > Stay connected, organized, and protected. Take the tour: > > http://tour.mail.yahoo.com/mailtour.html > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > Gareth Evans > > MSoft eSolutions Limited > Technology Centre > Inward Way > Rossmore Business Park > Ellesmere Port > Cheshire > CH65 3EN > > -- > Tel: +44 (0)870 0100 704 > Fax: +44 (0)870 9010 705 > E-Mail: [EMAIL PROTECTED] > Web: www.msoft.co.uk > > ---------------------------------------------- > Terms: > Please note that any prices quoted within this e-mail are subject to VAT. > All program details and code described in this e-mail are subject to > copyright (c) of MSoft eSolutions Limited and remain the intellectual > property of MSoft eSolutions Limited. > Any proposal or pricing information contained within this e-mail are > subject to MSoft eSolutions' Terms and Conditions > ---------------------------------------------- > Disclaimer: > This message is intended only for use of the addressee. If this message > was sent to you in error, please notify the sender and delete this > message. MSoft eSolutions Limited cannot accept responsibility for viruses, > so please scan attachments. Views expressed in this message do not > necessarily reflect those of MSoft eSolutions Limited who will not > necessarily be bound by its contents. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- -- Rokibul Islam Khan Software Developer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]