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
  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')]
  3. 0

    Prepared Statements: setDate type

    Oracle Community | 1 decade ago | 843854
    java.sql.SQLException: You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'Co ntactNo ) values ('asdf', 'asdf', 'd', '1973-04-08', 'asdf', 'adsf')' at line 1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Using a custom exception sorter | JBoss Developer

    jboss.org | 1 year ago
    java.sql.SQLException: ORA-20001: asdf ORA-06512: at "KAKE.A_NIK_TEST", line 3
  6. 0

    Prepared Statements: setDate type

    Oracle Community | 1 decade ago | 843854
    java.sql.SQLException: You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'Co ntactNo) values ('234', 'fdsf', 'f', '1987-04-03', 'asdf', '214'' at line 1

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    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