What exception will be thrown when selecting a MySQL record that is locked with "FOR UPDATE"?
1 answer
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 synchronized
in Java. The JVM does not throw an exception when a thread tries to enter a block synchronized
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.
+1
source to share