struts: OK to subclass beans?

Discussion in 'Java' started by Tom, Sep 16, 2003.

  1. Tom

    Tom Guest

    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
     
    Tom, Sep 16, 2003
    #1
    1. Advertising

  2. Tom

    Scott Yanoff Guest

    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
     
    Scott Yanoff, Sep 18, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Torsten Schmeissel
    Replies:
    0
    Views:
    431
    Torsten Schmeissel
    Apr 29, 2005
  2. jstorta
    Replies:
    3
    Views:
    457
    jstorta
    Feb 20, 2006
  3. S.Volkov
    Replies:
    2
    Views:
    231
    S.Volkov
    Mar 12, 2006
  4. Trans
    Replies:
    8
    Views:
    332
    Robert Klemme
    Oct 23, 2008
  5. Fab

    Subclass of subclass

    Fab, Aug 9, 2012, in forum: C++
    Replies:
    0
    Views:
    403
Loading...

Share This Page