Holding Static data links?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    Holding Static data links?


    Hello!

    I have designed a website with a servlet that holds on to a database
    connection statically so as not to have to re-establish the data connection
    with every single page request. (and it detects if the link went down, of
    course). This connection has a bunch of prepared statements on it to make
    things easier.

    Now, the question is: Am I begging for trouble by doing this? What
    happens if two page requests come in extremely close together? Is there a
    guarantee that the servlet will only process one page at a time? Could it
    be that two page requests will come in and cause the database connections
    to step on each other?

    Thanks!

    mark.



    --
    -- I am not an ANGRY man. Take the rage out of my e-mail address to reply
    please.
  • Stephen David

    #2
    Re: Holding Static data links?

    Mark,

    Servlets are multi-threaded -- if you're saying that each instance of your
    servlet gets its own database connection (preferrably from a connection
    pool), then you should be okay. On the other hand, if you have a database
    connection that is a singleton object that you're sharing between servlet
    threads, i believe you may be asking for trouble.

    I'd recommend utilizing third party connection pooling software, as it will
    take care of 'dead' connections, keeping a min/max # of connections open,
    etc. For decent open-source connection pooling software, check out
    http://proxool.sourceforge.net/.

    Steve David

    Mark <news@ANGRYlanf ear.com> wrote in message news:<R7v2c.130 526$4o.169281@a ttbi_s52>...[color=blue]
    > Hello!
    >
    > I have designed a website with a servlet that holds on to a database
    > connection statically so as not to have to re-establish the data connection
    > with every single page request. (and it detects if the link went down, of
    > course). This connection has a bunch of prepared statements on it to make
    > things easier.
    >
    > Now, the question is: Am I begging for trouble by doing this? What
    > happens if two page requests come in extremely close together? Is there a
    > guarantee that the servlet will only process one page at a time? Could it
    > be that two page requests will come in and cause the database connections
    > to step on each other?
    >
    > Thanks!
    >
    > mark.[/color]

    Comment

    Working...