title: ORA-00060: deadlock detected while waiting for resource while updating multiple rows in a multi-threaded system
body: <p>Earlier I used this query where I was updating 100 rows one by one.</p>
  
  <pre><code>String query="update table set status=? where  rownum&lt; ?";
  stmt = conn.prepareStatement(query);
  for(int i=0; i &lt; CHUNK_SIZE;i++){
      stmt.setString(1, "STATUS_IN_PROGRESS");
      stmt.setInt(2, 2);
      stmt.executeUpdate();
      }
  </code></pre>
  
  <p>Now I changed this query to update all the rows at once.</p>
  
  <pre><code>String query="update table set status=? where  rownum&lt; ?";
  stmt = conn.prepareStatement(query);
  stmt.setString(1, "STATUS_IN_PROGRESS");
  stmt.setInt(2, CHUNK_SIZE);
  </code></pre>
  
  <p>But the later one is giving " ORA-00060: deadlock detected while waiting for resource" exception. I read about <a href="http://www.dba-oracle.com/t_deadlock.htm" rel="nofollow">this</a> but I am not able to understand that if the exception is because of competing DMLs then it should have happened in the first query also though with a lower probability but that was non the case.</p>
  
  <p>Also we normally do frequent updates at DB level so it should be  a frequent problem but this is not the case.</p>