• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in simulteneous access to the same servlet

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well done guys.All r doing a good job.
I have a problem in connecting the servlet with the database(Interbase).When I load the servlet it connect the database and display a form.If I run it in the browser it is fine;Working as expected.But if I try to load the SAME servlet simultaneously in 2 browsers the 1 browser displays.Other browser doesn't(it is stuck with an error message).
Why it is so?Therafter I synchronized the method(doget) in the servlet and tried.It is working for simultaneous access.(but there is a time interval in loading the reply in the browser since I have synchronized the servlet).
I know one thing for sure.That is no problem in creating connections by the database bcos I tried with two DIFFERENT servlet simultaneously.It is loading the output in the browser.
Please somone help me.

[This message has been edited by sukathis_1 (edited November 20, 2000).]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like your servlet is trying to reuse the same Database connection which is already in use by the first. What you need is a connection pool. I recommend you get the software DbConnectionBroker from Java Exchange and use it.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Carl,
It looks this will sort out my problem
Regards
Sukathis
 
miguel lara
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We're having the same problem even though we're using the
DbConnectionBroker. We're using MySql and Tomcat. When users
submit the same html form simultaneously in 2 browsers, only one displays data, the other one displays the error: javax.servlet.ServletException: Column 'studentId' not found.
The name of the column varies according to the table we're using.
Even WORST, after clicking simultaneously sometimes both browser display the SAME information, this is a BIG issue since one user will get the information from the other one.
We have set up the DbConnectionBroker parameters in the following way:
int MINCONNS = 5;
int MAXCONNS = 20;
int CLEANUP = 1;
Your comments, tips and help will be GREATLY appreciated.

[This message has been edited by miguel lara (edited May 25, 2001).]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sukathis_1",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
Thanks.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the problems are in Servlets it sounds like you are having a thread problem. In an Application server there (should) only ever exist a single instance of a servlet and all requests get fed through the same servlet. Therefore if you maintain the DB Connection or any other variable as a class variable it can be changed by any of the threads passing through the code.
To fix this is either make the servelt thread safe or if that isn't possible, make it implement the SinngleThreadModel. This is used as a flag to indicate that only one thread should be allowed access to the servlet at a time.
Dave.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic