org.h2.jdbc.JdbcSQLException

Unique index or primary key violation: "UC_COUNTRIES_SLUG_INDEX_F ON PUBLIC.COUNTRIES(SLUG) VALUES ('test', 3)"; SQL statement: INSERT INTO countries ( name , name_ru , slug , created_at , created_by , updated_at , updated_by ) VALUES ( ? , ? , ? , ? , ? , ? , ? ) [23505-192]

Samebug tips1

Check if you're not creating unused SQL entities, as it might cause this exception.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web1160

  • Unique index or primary key violation: "UC_COUNTRIES_SLUG_INDEX_F ON PUBLIC.COUNTRIES(SLUG) VALUES ('test', 3)"; SQL statement: INSERT INTO countries ( name , name_ru , slug , created_at , created_by , updated_at , updated_by ) VALUES ( ? , ? , ? , ? , ? , ? , ? ) [23505-192]
  • Unique index or primary key violation: "UC_CATEGORIES_SLUG_INDEX_6 ON PUBLIC.CATEGORIES(SLUG) VALUES ('test', 5)"; SQL statement: INSERT INTO categories ( name , name_ru , slug , created_at , created_by , updated_at , updated_by ) VALUES ( ? , ? , ? , ? , ? , ? , ? ) [23505-192]
  • Unicity Index Violation or Primary Key: "PRIMARY_KEY_A ON PUBLIC.RECORD(CODRECORD) VALUES ('AGR', 3)" Unique index or primary key violation: "PRIMARY_KEY_A ON PUBLIC.RECORD(CODRECORD) VALUES ('AGR', 3)"; SQL statement: insert into RECORD (estado, icono, nombre, codRECORD) values (?, ?, ?, ?) [23505-192]
  • Stack trace

    • org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "UC_COUNTRIES_SLUG_INDEX_F ON PUBLIC.COUNTRIES(SLUG) VALUES ('test', 3)"; SQL statement: INSERT INTO countries ( name , name_ru , slug , created_at , created_by , updated_at , updated_by ) VALUES ( ? , ? , ? , ? , ? , ? , ? ) [23505-192] at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:900) at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:318) at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:299) at ru.mystamps.web.dao.impl.JdbcCountryDao.add(JdbcCountryDao.java:87) at ru.mystamps.web.service.CountryServiceImpl.add(CountryServiceImpl.java:76) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:68) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) at com.sun.proxy.$Proxy138.add(Unknown Source) at ru.mystamps.web.controller.CountryController.processInput(CountryController.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "UC_COUNTRIES_SLUG_INDEX_F ON PUBLIC.COUNTRIES(SLUG) VALUES ('test', 3)"; SQL statement: INSERT INTO countries ( name , name_ru , slug , created_at , created_by , updated_at , updated_by ) VALUES ( ? , ? , ? , ? , ? , ? , ? ) [23505-192] at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.get(DbException.java:179) at org.h2.message.DbException.get(DbException.java:155) at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103) at org.h2.mvstore.db.MVSecondaryIndex.checkUnique(MVSecondaryIndex.java:231) at org.h2.mvstore.db.MVSecondaryIndex.add(MVSecondaryIndex.java:190) at org.h2.mvstore.db.MVTable.addRow(MVTable.java:704) at org.h2.command.dml.Insert.insertRows(Insert.java:156) at org.h2.command.dml.Insert.update(Insert.java:114) at org.h2.command.CommandContainer.update(CommandContainer.java:98) at org.h2.command.Command.executeUpdate(Command.java:258) at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:160) at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:146) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:903) at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:900) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629) ... 37 more

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    2 times, 8 months ago
    23 times, 1 month ago
    4 times, 3 months ago
    4 times, 4 months ago
    15 times, 6 months ago
    143 more bugmates