would the DB's will not have an internal lock for their operations??.  is it
mandatory to make the DB object static for DB operations.

For example in an online reservation system if you have only one ticket left
and 2 users are trying to reserve at the same milliseconds i believe DB will
not entertain both of their request.  Am i right??.

Cheers
Srini

-----Original Message-----
From: Raj Kumar Jha [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 10, 2000 11:33 AM
To: [EMAIL PROTECTED]
Subject: Re: Synchronize method in the servlet


It works even if my method is non-static but the database object has to be
static.
Regards,
Raj

----- Original Message -----
From: Peter Pilgrim
To: [EMAIL PROTECTED]
Sent: Tuesday, October 10, 2000 4:02 PM
Subject: Re: Synchronize method in the servlet


Yes my mistake the `databaseLock' has to be static because the method
is static method and cannot there access a non-static individual attribute.
--

Peter Pilgrim
Welcome to the "Me Too" generation.



---------------------------------------- Message
History ----------------------------------------


From: [EMAIL PROTECTED] on 10/10/2000 08:29

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Synchronize method in the servlet



Hi,
   I tried this but it doesnt work if I dont declare the databaseLock as
static. Do I need to declare it as static ?

BTW: The databaseLock is just an example of code. You might have
another a class and a method that provides the lock for you as
a single point of accessing the database.

               synchronized ( DBPool.getDatabaseLock() ) {
               ..
          }

PS: Most database will provide locking of tables implicity,
integrity of information, otherwise it is __not__ a DB. So
the above in general is not required.


Thanx and Regards,
Raj

----- Original Message -----
From: Peter Pilgrim
To: [EMAIL PROTECTED]
Sent: Friday, October 06, 2000 3:56 PM
Subject: Re: Synchronize method in the servlet


You said that you ONLY want one thread ever accessing/updating the
DB at any one time. So why I have a custom `Object' that locks your
database.


class DBMethoden {

     protected Object databaseLock = new Object();

     ...

     void doFunkyPigeon() throws SQLException
     {
          synchronized ( databaseLock ) {
               DBPool pool = DBPool.getInstance();
               Connection conx = pool.acquire();
               try {
                    funkyPigeon101( conx );
               }
               finally {
                    pool.release( conx );
               }
          }
     }

}


--

Peter Pilgrim
Welcome to the "Me Too" generation.



---------------------------------------- Message
History ----------------------------------------


From: [EMAIL PROTECTED] on 05/10/2000 15:44

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Synchronize method in the servlet



The reason I think I have to put static keyword for the method is because my
method is going to update the database by JDBC connection. I don't want
multiple
thread updating the database at the same time.

Here is my code:

public static synchronized String assignNum(String name, String uID, String
requestType, String comment){

    String rID = "";
    try{
        rID = db.DBinsert(name, uID, requestType, comment);
        db.updateSeqNum(requestType);

    } catch (Exception e) {
        System.err.println(e.toString());
    }
    return rID;
}

Thanks for the replys.

Tiana

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html





--

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html





--

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to