Solved

How can i synchronize table data?

Posted on 2011-03-25
9
364 Views
Last Modified: 2012-05-11
Dear Experts,

I have a table called EMPLOYEE, suppose if two employees are trying to update the same filed data in that table. how can i avoid this?  
0
Comment
Question by:haneef_nb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 35215267
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35215322
Is this a Java q or an Oracle one?
0
 
LVL 17

Accepted Solution

by:
Dejan Pažin earned 500 total points
ID: 35215361

If for example you are using Hibernate, you can have optimistic locking auto implemented for you by version attribute on the entity:

Each time before a change is submited to the database the version attribute is checked and if it is not the in the database as on the entity, then someone has changed the content and the transaction will not be commited. You will have to read the entity again and then save it (and the sam procedure will occure). Once the change is approved, the version attribute is increased.

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35217493
@ CEHJ

Say correct you can do it in 2 ways !!

in oracle auto commit off then commit while your finish your job !!

0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35217677
From an Oracle (or just about any RDBMS), you really don't need to worry about this. The first update will lock the row will get it. The second update will block until the lock is released.

You may have an application issue that you need to work out if two people update the same field about the same time, the 'locked' update is not aware of the previous commit. It might generate some bad data. ÿ 

You will need to control that at the application layer.
For example:
user1: update emp set salary=salary*10 where emp_id=1;
user2: update emp set salary=salary*10 where emp_id=1;
user1: commit;
user2: commit;

What is the 'new' salary for employee?
0
 

Author Comment

by:haneef_nb
ID: 35224560
Dear Experts,

i want in both ways, in Oracle & Java..

Please explain in brief in both the ways..
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35224565
There is no 'both' ways.  There is how the RDBMS handles row locking then how a the app makes the calls.

Oracle is the RDBMS and Java is the app layer making calls to the RDBMS.  They really aren't the same.
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35224859
in oracle auto commit off then commit while your finish your job !!
0
 

Author Closing Comment

by:haneef_nb
ID: 35376531
Thanks..
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help on decision table structure 7 58
Oracle Query to Find number of process consumed by a session 15 70
Java array sort 10 62
Oracle performance tuning 2 55
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question