• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in simulteneous access to the same servlet

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Carl,
It looks this will sort out my problem
Regards
Sukathis
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic