在等待资源ORA-00060时检测到死锁

时间:2015-01-21 18:58:05

标签: java database spring oracle

使用多线程时出现以下错误。如果使用一张OFROSTER表,怎么可能? 据我所知,如果有两个表同时由两个会话更新,则可能会发生这种错误。 使用Oracle 12c,Spring 3.1

       ApplicationLogger: SQLException occured in updateRoster,txnId:S4H9RA2T2389478
        org.springframework.dao.DeadlockLoserDataAccessException: PreparedStatementCallback; 

SQL [MERGE INTO OFROSTER R1 USING (SELECT 1 FROM DUAL) R2 ON (R1.USERNAME = ? AND R1.JID=?) 
    WHEN MATCHED THEN UPDATE SET R1.NICK = ? WHERE (R1.NICK IS NULL) 
    WHEN NOT MATCHED THEN INSERT (R1.ROSTERID, R1.USERNAME, R1.JID, R1.SUB, R1.ASK, R1.RECV) VALUES (ROSTER_SEQ.NEXTVAL,?,?,?,?,?)]; ORA-00060: deadlock detected while waiting for resource
        ; nested exception is java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource

                at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:265)
                at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
                at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
                at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:615)
                at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:884)
                at org.springframework.jdbc.object.BatchSqlUpdate.flush(BatchSqlUpdate.java:184)

0 个答案:

没有答案