java database connection question

Discussion in 'OT Technology' started by babygodzilla, Nov 26, 2007.

  1. babygodzilla

    babygodzilla I love rice

    Joined:
    Nov 5, 2001
    Messages:
    3,108
    Likes Received:
    0
    im not sure how to design my code to run queries. right now i have a separate class for every table i have in my DB that contains static functions to just run queries, and all of them must take a Connection as an argument.

    my question is, how do i handle these Connections? what I am doing right now is everytime I need to run a query, I open a Connection, do whatever I need to do, and when I'm done, close that Connection. This seems redundant, but I don't have much experience in design so I really don't know what the best method to do this is. Should I have just one persistent Connection all the way through. If so, how do I know when to close the Connection?

    are there resources that teach you this kind of design stuff?

    thanks
     
  2. babygodzilla

    babygodzilla I love rice

    Joined:
    Nov 5, 2001
    Messages:
    3,108
    Likes Received:
    0
    gah... i just read about Connection Pooling and i think thats what i should be doing :(

    any particular tutorial anyone wanna recommend me? thanks
     

Share This Page