Forums Register Login
how database handle request?
Hi friend,

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.
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.
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

Here is a great article from DB2 Universal Database Online Information: https://aurora.vcu.edu/db2help/db2d0/frame3.htm#integ

Levels in JDBC and how they relate to DB2 levels

How do the DB2 levels affect data?

[ May 01, 2006: Message edited by: Stan James ]
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database

This thread has been viewed 1065 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 18, 2019 14:42:02.