What exception will be thrown when selecting a MySQL record that is locked with "FOR UPDATE"?
I believe no exception will be thrown, the call to the Java thread will simply block until the RDBMS releases the blocked data. This is normal, so you need to throw an exception. Think of it as analogous to a block
in Java. The JVM does not throw an exception when a thread tries to enter a block
that is already occupied by another thread.
The only situations in which an exception can be thrown are:
- When the connection to the RDBMS is lost,
- When the RDBMS detects a deadlock with a concurrent transaction.
source to share