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

          No work has yet been logged on this issue.

            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, 1 day ago