Why don't you use a singleton and avoid the overhead of contacting your
servlet? Is it because you want to share your connection accross different
machines? If so, what happen to your socket for your open connections from
the pools when that connection is returned to the caller?
-----Original Message-----
From: Christopher Cobb [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 18, 1999 7:41 AM
To: [EMAIL PROTECTED]
Subject: Re: Database locking in multiple page Web application
It is more efficient to have one database connection that you reuse
between pages.
I use a "stand-alone" database access servlet. This servlet has two
purposes:
1) When the servlet starts up, make a database connection.
2) Each time the servlet receives a GET or POST, it attaches the
connection to the current session, and then forwards to the destination
page.
It is used like this:
http://localhost/servlet/dbaccess/destination.html
With a strategy like this, you can use a single connection across many
page.
This is complicated a little by updates. Each time you do an update
transaction (which may involve multiple statements) you should do this
in a separate connection. I do this with a connection pool. When the
update transaction is over, I don't close the connection, but I leave it
open and put it back into the connection pool. This way, the connection
is available for use with the next update transaction without having to
go through the overhead of reopening the connection.
cc
Chee Keong wrote:
> Thank you for your response.
>
> Assume that I use Oracle or Informix which supports
> SELECT FOR UPDATE. However, I am still not sure how it would work
> across multiple web pages the the JDBC connection would be closed.
>
> The user would update the data on Page A and click a "Next Page Info"
> link. The user would then proceed to update data on page B., etc
>
> Finally, the use clicks Update . How can I prevent other users to
> be able to select the same record for update at the same time ?
>
> As I understand it, I would load the JDBC driver, connect to the
> database , perform some SQL statements and close off the connection
> withing the same JSP or servlet.
>
> Is the record still locked although my JDBC connection is closed and
> can I update this record in another JSP or servlet ?
>
> Regards,
> Chee Keong.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html