Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simultaneous access to a db from a servlet

 
Subbu Aswathanarayan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeff Sunder
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic