Created
October 22, 2014 01:22
-
-
Save yuba/c9443edf59b7e89a7cf9 to your computer and use it in GitHub Desktop.
JavaでRDBデッドロック検出 ref: http://qiita.com/yuba/items/46e65d546ae3c723222b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
// 永続化操作 | |
} catch (SQLException sqle) { // SQLExceptionを投げるフレームワークの場合 | |
if ("40001".equals((sqle).getSQLState())) { | |
// デッドロック | |
} | |
else throw sqle; | |
} catch (PersistenceException pe) { // PersistenceExceptionを投げるフレームワークの場合 | |
Throwable cause = pe.getCause(); | |
if (cause instanceof SQLException && "40001".equals(((SQLException)cause).getSQLState())) { | |
// デッドロック | |
} | |
else throw pe; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment