I came across MySQLTransactionRollbackException
exception today and the error message is Deadlock found when trying to get lock; try restarting transaction
. I analysed the code and found that there are many update/insert statements in the same transaction and the transaction is committed in the end. I found many PreparedStatement.executeQuery()
calls in between. Does PreparedStatement.executeQuery()
call obtains a lock? What could be the other possible reason for the deadlock? I tried googling but no luck. I read this and this but did not get my answer.
Any references to some standard documentation will be helpful. I am using MySQL(InnoDB).