title: Java Data Synchronisation with database
body: <p>I have an application that permit the users to save data into a database. These date have constraints, for example :
  Two data can't have the same value.
  The idea is when you try to save data, the program will look into the database and see if there is a data with the same value, if there is, the program will show an exception, if not it will save the data. The problem is what if two threads save their data at the same time and those data have the same value, how can I prevent that from happening.
  Any suggestions ?</p>