struts: OK to subclass beans?

T

Tom

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
 
S

Scott Yanoff

Tom said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top