Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > struts: OK to subclass beans?

Reply
Thread Tools

struts: OK to subclass beans?

 
 
Tom
Guest
Posts: n/a
 
      09-16-2003
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


 
Reply With Quote
 
 
 
 
Scott Yanoff
Guest
Posts: n/a
 
      09-18-2003
Tom wrote:

> 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?


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,


--
-Scott
| http://www.yanoff.org | AOL IM: SAY KJY

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subclass of subclass Fab C++ 0 08-09-2012 09:54 AM
subclass a class in the namespace of the that subclass Trans Ruby 8 10-23-2008 07:24 AM
String subclass method returns subclass - bug or feature? S.Volkov Ruby 2 03-12-2006 06:46 PM
subclass has a variable that is subclass of same superclass jstorta Java 3 02-20-2006 08:42 PM
TreeNode subclass Booshmon ASP .Net 0 10-04-2005 08:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57