This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes simultaneous access to a db from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "simultaneous access to a db from a servlet" Watch "simultaneous access to a db from a servlet" New topic
Author

simultaneous access to a db from a servlet

Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
Hi all,
i am new to jdbc as well as servlets.
i am using MS SQL Server as my db and drivers provided by "JRun " in one of my servlet.my servlet may be accessed by more than one user at the same time.
they may try to write to different records of the same table.
i was told that to avoid conflict between the two statements, we have to set up buffering to either optimistic or pesimistic while getting the resultset.
i have no idea what that means or how to set it up.
any help in this regard will be greatly appreciated.
my system info
JRun3.1/IIS 4.0/NT 4.0/MS SQL Server
Subbu

Subbu
Jeff Sunder
Ranch Hand

Joined: Jun 26, 2001
Posts: 47
You need to set up a connection pool. A connection pool will allow for multiple simultaneous users to access your db. This will also reduce the overhead because it recycles connections rather than create new connections for every new user. Look at the CoonectionPool class to get started.
Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
Hi Jeff,
I think i didn't word my question correctly.i will explain it once again.
my problem is not connection pooling.as a matter of fact i am using connection pooling.my question is, what if two users try to update two different records of the same table.will the table get locked or just the record.someone mentioned to me that we can control if the entire table gets locked or just the record being updated.
i want to know how can this be done using java.
thanks for ur reply.
Subbu
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
If I remembered corretly, MS SQL Serve does record locking. For multi-access, you don't need to code that in Java. Any good database system should be able to handle it correctly.
 
 
subject: simultaneous access to a db from a servlet
 
Similar Threads
no sqljdbc_auth in java.library.path
Configuring database on local machine
Connection...
Remote JDBC connection performance question
WSAD 5.0 vs. WAS 4.0 Data source config