java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')]

Spring JIRA | Henryk Paluch | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    There is an problem in JPetStore application. When a new user attempts to registers itself on: http://localhost:8080/jpetstore/shop/newAccount.do there is not handled the case, when entered user id already exists. For example for User ID: j2ee on submit error is displayed: ------------------------------------------------------------- org.springframework.dao.DataIntegrityViolationException: SqlMapTemplate: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')]; nested exception is java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')] java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')] at com.ibatis.db.sqlmap.MappedStatement.executeUpdate(Unknown Source) at org.springframework.orm.ibatis.SqlMapTemplate$8.doInMappedStatement(SqlMapTemplate.java:218) at org.springframework.orm.ibatis.SqlMapTemplate.execute(SqlMapTemplate.java:111) at org.springframework.orm.ibatis.SqlMapTemplate.executeUpdate(SqlMapTemplate.java:216) at org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao.insertAccount(SqlMapAccountDao.java:24) at org.springframework.samples.jpetstore.domain.logic.PetStoreImpl.insertAccount(PetStoreImpl.java:74) ---------------------------------------------------------- Please note, that it is very common problem on user registration. It would be nice to fix this sample to have nice reference implementation. I like to provide fix, but have no idea, how to make custom errors in onSubmit() method of AccountFormController (it is not obvious how to do this).

    Spring JIRA | 1 decade ago | Henryk Paluch
    java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')]
  2. 0

    There is an problem in JPetStore application. When a new user attempts to registers itself on: http://localhost:8080/jpetstore/shop/newAccount.do there is not handled the case, when entered user id already exists. For example for User ID: j2ee on submit error is displayed: ------------------------------------------------------------- org.springframework.dao.DataIntegrityViolationException: SqlMapTemplate: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')]; nested exception is java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')] java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')] at com.ibatis.db.sqlmap.MappedStatement.executeUpdate(Unknown Source) at org.springframework.orm.ibatis.SqlMapTemplate$8.doInMappedStatement(SqlMapTemplate.java:218) at org.springframework.orm.ibatis.SqlMapTemplate.execute(SqlMapTemplate.java:111) at org.springframework.orm.ibatis.SqlMapTemplate.executeUpdate(SqlMapTemplate.java:216) at org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao.insertAccount(SqlMapAccountDao.java:24) at org.springframework.samples.jpetstore.domain.logic.PetStoreImpl.insertAccount(PetStoreImpl.java:74) ---------------------------------------------------------- Please note, that it is very common problem on user registration. It would be nice to fix this sample to have nice reference implementation. I like to provide fix, but have no idea, how to make custom errors in onSubmit() method of AccountFormController (it is not obvious how to do this).

    Spring JIRA | 1 decade ago | Henryk Paluch
    java.sql.SQLException: Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')]

    Root Cause Analysis

    1. java.sql.SQLException

      Violation of unique index: PK_ACCOUNT in statement [insert into ACCOUNT (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) values ('asdf', 'asdf', 'asdf', 'OK', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'j2ee')]

      at com.ibatis.db.sqlmap.MappedStatement.executeUpdate()
    2. com.ibatis.db
      MappedStatement.executeUpdate
      1. com.ibatis.db.sqlmap.MappedStatement.executeUpdate(Unknown Source)
      1 frame
    3. Spring ORM
      SqlMapTemplate.executeUpdate
      1. org.springframework.orm.ibatis.SqlMapTemplate$8.doInMappedStatement(SqlMapTemplate.java:218)
      2. org.springframework.orm.ibatis.SqlMapTemplate.execute(SqlMapTemplate.java:111)
      3. org.springframework.orm.ibatis.SqlMapTemplate.executeUpdate(SqlMapTemplate.java:216)
      3 frames
    4. org.springframework.samples
      PetStoreImpl.insertAccount
      1. org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao.insertAccount(SqlMapAccountDao.java:24)
      2. org.springframework.samples.jpetstore.domain.logic.PetStoreImpl.insertAccount(PetStoreImpl.java:74)
      2 frames