Announcement Announcement Module
Collapse
No announcement yet.
catching DataIntegrityViolation exception in web tier Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • catching DataIntegrityViolation exception in web tier

    Hi all,

    I have UserAlreadyExistsException that extends DataIntegrityViolationException. I try to catch this exception in web tier with the following code. But it does not give error message to screen instead it gives exception in browser.
    I've flushed db in dao layer.

    Code:
            Object[] args = new Object[] {user.getUserName()};
                try {
                	mgr.saveUser(user); 
                } catch (UserAlreadyExistsException e) {
                    log.warn(e.getMessage());
                    errors.reject("exception.alreadyExists", args, "User Exists");
                }
    
                saveMessage(request,getText("messages.saved", args, locale));
    
            return new ModelAndView(getSuccessView());

  • #2
    What persistence technology are you using? What exception do you see in the browser?

    Comment


    • #3
      Hi Rod,
      I'm using Hibernate as persistance technology. My exception code is below and also the exception. I throw my exception in service layer and want to catch in formController or is there any way 2 do this.
      Thanks,
      Best Regards

      Code:
      public class UserAlreadyExistsException extends Exception {
          public UserAlreadyExistsException(String message) {
              super(message);
          }
      }
      org.springframework.dao.DataIntegrityViolationExce ption: HibernateTemplate: One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "2" constrains table "DB2ADMIN.USERS" from having duplicate rows for those columns.; nested exception is com.ibm.db2.jcc.b.SQLException: 2;DB2ADMIN.USERS[/code]

      Comment

      Working...
      X