• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

how database handle request?  RSS feed

Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!