What exception will be thrown when selecting a MySQL record that is locked with "FOR UPDATE"?

I want to use JDBC to access MySQL database. Which or will throw SQLException if I manage to select a row that was previously locked by the "SELECT ... FOR UPDATE" statement.

Thank.

+3


source to share


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







All Articles