Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can i synchronize table data?

Posted on 2011-03-25
9
Medium Priority
?
368 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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses

730 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