Tiana Zhang wrote:
>
> 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.
>
> 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;
> }
>

 - Milt's message had some more good questions

 - Are you absolutely 100% sure your database code works?

 - Put in some println's. Include the current thread id.
   Put one at the start of the routine, one at the end.
   Are there every really two threads in the routine at
   once? Or is it some other problem, like you're assigning
   the results of assignNum to a variable that's shared
   between threads?

 - Classloaders can be tricky (see milt's questions). Are
   you 100% sure only a single copy of the class is being
   loaded and used?

 - Post more code, specifically the service(), get() or
   post() routine that's calling assignNum().

 If I had to bet on the problem, I'd bet is was assigning the
results of assignNum() to a shared variable (but there's no
way to tell without more code :-)


-cks

___________________________________________________________________________
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