File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes web application concurrent access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "web application concurrent access" Watch "web application concurrent access" New topic
Author

web application concurrent access

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
A web application is connected to a database (for example oracle),if many user access the web application and try to insert data in same table at time ,

1) how the application behaves?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It depends. Do you have a more specific question? Yours really doesn't provide any basis for a meaningful answer.
Alpesh Padra
Ranch Hand

Joined: Jan 10, 2010
Posts: 41
You will have to design your application in such a way that concurrent db access should not happen.

Make you connection class thread-safe or use connection pooling. so that at a time only specific number of user will going to access your DB.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
You will have to design your application in such a way that concurrent db access should not happen.

There's nothing wrong with concurrent DB access. Simultaneous inserts into a table pose no particular issue (simultaneous updates do). Any DB write access should be guarded by transactions, of course.

Make you connection class thread-safe or use connection pooling. so that at a time only specific number of user will going to access your DB.

All code must be thread-safe, and DB transactions must be used. Then it doesn't matter if there are 2 simultaneous users or 2000.


Ping & DNS - my free Android networking tools app
Scott Bravo
Greenhorn

Joined: Jun 15, 2009
Posts: 18
All code must be thread-safe, and DB transactions must be used. Then it doesn't matter if there are 2 simultaneous users or 2000.


I guess in this case Application response time would increase if it is 2000 users ... Best is make only that part of code as thread safe which is critical for transactions.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Scott Bravo wrote:Best is make only that part of code as thread safe which is critical for transactions.

No. *All* code must be thread-safe. That 2000 users put a higher strain on a system than 2 users goes without saying, but that's not a concurrency issue, that's a load/performance issue.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

+1

@Scott: don't confuse "thread-safe" with "having to do something". For example, a method that accesses no data outside of its own state is thread-safe by definition. Issues arise only when accessing state that other threads may also access.
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
Hi all

if the user access the same table ,I do not want to make them wait till the current user release the Lock,that is ,all the user update same table as they wish.

How to handle this scenario?


Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

jacob deiter wrote:Hi all

if the user access the same table ,I do not want to make them wait till the current user release the Lock,that is ,all the user update same table as they wish.

How to handle this scenario?




Why would you lock the table for an update? Locks in databases happen at a lower level than the table itself - can't you just rely on this out the box behaviour?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

That's what transactions are for.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web application concurrent access