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. Advertisements

  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. Advertisements

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. john butorac

    <beans> and struts basics

    john butorac, Apr 14, 2004, in forum: Java
    Replies:
    0
    Views:
    653
    john butorac
    Apr 14, 2004
  2. Daniel

    nested beans in struts?

    Daniel, Jan 13, 2005, in forum: Java
    Replies:
    7
    Views:
    9,323
    Sudsy
    Jan 14, 2005
  3. D. Mantelos
    Replies:
    9
    Views:
    8,055
    smshashi
    May 3, 2007
  4. Torsten Schmeissel
    Replies:
    0
    Views:
    620
    Torsten Schmeissel
    Apr 29, 2005
  5. jstorta
    Replies:
    3
    Views:
    645
    jstorta
    Feb 20, 2006
  6. S.Volkov
    Replies:
    2
    Views:
    416
    S.Volkov
    Mar 12, 2006
  7. Trans
    Replies:
    8
    Views:
    557
    Robert Klemme
    Oct 23, 2008
  8. Fab

    Subclass of subclass

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