Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2003

Tip: Looking for answers? Try searching our database.

struts: OK to subclass beans?

Thread view: 
Tom - 16 Sep 2003 22:25 GMT
Hi,

   I have a rather simple question:  I would rather use a connection pool
but at the moment I need a quick solution to access a db. Right now I have
some beans which each have their own method to get a datbase connection, and
later release it. What I want to do is create a base class with these two
methods implemented and then all the beans subclassed from it so if I need
to change the db access code I only do it once.... Any comments or
suggestions? Is this a good way to handle this or would it be much better to
use the apache.commons.dbcp.BasicDataSource?

Thanks,

-Tomas
Scott Yanoff - 18 Sep 2003 19:51 GMT
> Hi,
>
[quoted text clipped - 6 lines]
> suggestions? Is this a good way to handle this or would it be much better to
> use the apache.commons.dbcp.BasicDataSource?

Can you just move the database connection stuff to a separate, generic
class and import that class in any of the beans that want to open a
connection to the database?  Of course, you'd have to make the methods
generic enough to be called by any of the beans.

HTH,

Signature

-Scott
yanoff@STOP-SPAMMINGyahoo.com | http://www.yanoff.org | AOL IM: SAY KJY



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.