I want to write a program that can access to multiple database based on the user ID, but I dont know how the database handle user request. Please help me...
if user A execute program and redirect to database abc, and user B also accessing it. user A retrieve value from database but not yet update it, at the same time user B go get the value. How can I control it? can I code a program that control if A not yet finish, we cannot allowed user B to retrieve the value?
I cannot use Java synchronization. if I use it, it will synchronize for all the request although the request is redirect to different database(I am using many databases but sharing 1 program). There is no point to do synchronization if another user accessing other database that is no user at that moment but still need to wait user at different database finish their tasks first.
Post by:Maximilian Xavier Stocker
This is one part of what makes database transactions useful. The part you are interested in appears to be the transaction level. There are multiple levels of transactiosn supported by database. (You can get a quick overview of what's available by looking at the constants in java.sql.Connection).
What your database actually supports I do not know because you haven't identified what database you are using.
Post by:Stan James
Look up "isolation levels" in your database documentation. The db vendors have different names for the same concepts and someplace the doc will tell you which ones your db supports and how they map to the standard JDBC words.
Here are some notes on isolation & DB2. Your db may be similar.
Isolation Levels in DB2
Repeatable Read (RR) locks all the rows an application references within a unit of work.
Read Stability (RS) locks only those rows that an application retrieves within a unit of work
Cursor Stability (CS) locks any row accessed by a transaction of an application while the cursor is positioned on the row.
Uncommitted Read (UR) does not lock other applications out of the row it is reading, unless the other application attempts to drop or alter the table