Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-2617

Uncategorized data access exception thrown for deadlock

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.6
    • Fix Version/s: None
    • Component/s: Data
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      During update by using JdbcTemplate.update(String sql, Object[] args), I encounter exception due to deadlock. This is thrown as an SQLException. Exception log is

      exception: PreparedStatementCallback; uncategorized SQLException for SQL [UPDATE EMP_INFO SET ORG_NAME=?, EMP_MAME=?, WHERE EMP_ID=?]; SQL state [40001]; error code [1205]; Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.; nested exception is java.sql.SQLException: Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

      In the above scenario, I encounter couple of issues:

      + From application program code there is no way I can capture this exception (SQLException), and provide the information message. To do this I am forced to capture root exception (Exception) and provide necessary information message.
      + Currently JdbcTemplate.update() method throws only 'DataAccessException' but when we look at source code we can see it internally executes PreparedStatementCallback.doInPreparedStatement() method, this method throws SQLException. But as root JdbcTemplate.update() throws only 'DataAccessException' so in this case I am not able to catch any SQLException. Please let me know is this a practice that I should not catch any SQLException in my application code?

        Issue Links

          Activity

          ilang98 Ilanchezhian created issue -
          juergen.hoeller Juergen Hoeller made changes -
          Field Original Value New Value
          Issue Type Bug [ 1 ] Improvement [ 4 ]
          Assignee Juergen Hoeller [ juergen.hoeller ]
          juergen.hoeller Juergen Hoeller made changes -
          Fix Version/s 2.0.7 [ 10605 ]
          Affects Version/s 2.0.6 [ 10604 ]
          Component/s SpringDA [ 10015 ]
          Summary Problem during usage of JdbcTemplate.update(String sql, Object[] args) Uncategorized data access exception thrown for deadlock
          Fix Version/s 2.1 M3 [ 10610 ]
          juergen.hoeller Juergen Hoeller made changes -
          Fix Version/s 2.1 M3 [ 10610 ]
          Fix Version/s 2.0.7 [ 10605 ]
          juergen.hoeller Juergen Hoeller made changes -
          Assignee Juergen Hoeller [ juergen.hoeller ] Thomas Risberg [ thomas.risberg ]
          Fix Version/s 3.0 RC1 [ 11289 ]
          juergen.hoeller Juergen Hoeller made changes -
          Fix Version/s 3.0 RC1 [ 11289 ]
          Fix Version/s 3.0 RC2 [ 11330 ]
          thomas.risberg Thomas Risberg made changes -
          Link This issue duplicates SPR-1690 [ SPR-1690 ]
          thomas.risberg Thomas Risberg made changes -
          Resolution Duplicate [ 3 ]
          Status Open [ 1 ] Resolved [ 5 ]
          tmarshall Trevor Marshall made changes -
          Workflow jira [ 15323 ] SPR Workflow [ 39712 ]
          cbeams Chris Beams made changes -
          Fix Version/s 3.0 RC2 [ 11330 ]
          tmarshall Trevor Marshall made changes -
          Workflow SPR Workflow [ 39712 ] New SPR Workflow [ 58585 ]
          tmarshall Trevor Marshall made changes -
          Workflow New SPR Workflow [ 58585 ] SPR Workflow [ 67554 ]

            People

            • Assignee:
              thomas.risberg Thomas Risberg
              Reporter:
              ilang98 Ilanchezhian
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                8 years, 8 weeks, 6 days ago