Solved

How can i synchronize table data?

Posted on 2011-03-25
9
359 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
  • 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
 
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 76

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 86
HSSFWorkbook cannot be resolved error 10 50
How to free up undo space? 3 29
Why  don't I see Below columns in my  Stored Procedure  under TMP_RS? 8 17
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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now