I have one MySql database instance with an Account table which maintains a Balance field. I have multiple Java applications each using a Jdbc to connect to the database that can potentially increase or decrease the value of the Balance field. How do I ensure that the Balance value is read, calculated and updated and that this process happens in isolation, and is 'aware' of any other Java processes that might be in the middle of doing the same thing?
The simple answer is to use transactions: http://dev.mysql.com/doc/refman/5.0/en/commit.html
However, in the case you describe, I much prefer not to store the balance of an account as a column in a table, but to calculate it by summing the value of the transactions related to that account. It's far less sensitive to the integrity issues you raise, and you're less likely to run into obscure locking scenarios.