my question is what precautions i have to take while coding servlets which has data manipulation commands. I have written a piece of code inside a doGet() method of a servlet.that code interacts with database ie. the code updates a record and insert a record.if thousands of people accessing the same servlent at the same time what will happen. will that servlet process all requests or will it throw an Exception.Do I have to take any care while writing this kind of code in a servlet.I want to avoid synchronization or synchronized block b'cos due to synchronization the servlet the servlet can't serve multiple clients at the same time.
You will probably be all right. All modern databases support the concept of "transactions", groups of operations which mustn't be interrupted. As long as you make sure that all database operations which your servlet performs during a single request are grouped as a transaction, then the database should be able to handle many simultaneous accesses without getting confused. For performance reasons, I would also recommend that you look into database connection pooling. If you continually have several servlets trying to access the database at once, you really don't want the overhead of opening a new connection for every request.