Announcement Announcement Module
No announcement yet.
through spring, catch the excepting then throws my exception Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • through spring, catch the excepting then throws my exception

    i want to throw myself exceptions through spring catch the exception
    so i define a DAOException

    try {
    catch (DataAccessException ex) {

    if (ex instanceof DataIntegrityViolationException) {
    throw new DAOException("Primary?? key exception in which key??");
    if (ex instanceof DataRetrievalFailureException) {
    throw new DAOException("connect exception");

    the question is:
    the spring doesn't differentiate "DataIntegrityViolationException" in detailed.
    i don't know which key confilcted or if there are more indexes,which index is confilcted or forgein key confilicted?
    what can i do??


  • #2
    Thats a general JDBC problem - we have to interpret the text in the message from the SQLException to determine which index/column is causing the problem. You might not even get the specific column but the name of a constraint. This part is dependent on which database you are using. So Spring can't really help you much here.