Skip to content

Instantly share code, notes, and snippets.

@yuba
Created October 22, 2014 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuba/c9443edf59b7e89a7cf9 to your computer and use it in GitHub Desktop.
Save yuba/c9443edf59b7e89a7cf9 to your computer and use it in GitHub Desktop.
JavaでRDBデッドロック検出 ref: http://qiita.com/yuba/items/46e65d546ae3c723222b
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