其他分享
首页 > 其他分享> > “违反唯一约束”错误的解决方案:

“违反唯一约束”错误的解决方案:

作者:互联网

首先报错信息:

[error][2022-04-19 14:36:13]:failed to access /smep/declaration/projectscorepage!saveExpertScore.page?$$time$$=20220419143611
net.cyan.thunwind.PersistenceSQLException: execute sql failed:Violate unique constraint on [MPSCOREDETAIL],sql:insert into MPSCOREDETAIL(DETAILID,NORMID,SCORE,EXPERTID,PROCESSID,OPERATORID) values(?,?,?,?,?,?),errorCode:-6602
    at net.cyan.thunwind.dialect.AbstractDialect.insert(AbstractDialect.java:668)
    at net.cyan.thunwind.RealSession.add(RealSession.java:585)
    at net.cyan.thunwind.dao.DaoHandler.add(DaoHandler.java:256)
    at com.gzzm.smep.declaration.ProcessDao$$javassist$$0.add(ProcessDao$$javassist$$0.java)
    at com.gzzm.smep.declaration.ProcessScorePage.saveExpertScore(ProcessScorePage.java:243)
    at com.gzzm.smep.declaration.ProcessScorePage$$javassist$$0.saveExpertScore(ProcessScorePage$$javassist$$0.java)
    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:498)
    at net.cyan.arachne.RequestContext.process0(RequestContext.java:981)
    at net.cyan.arachne.RequestContext.process(RequestContext.java:1241)
    at net.cyan.arachne.RequestContext.process(RequestContext.java:1174)
    at net.cyan.arachne.PageServlet.process(PageServlet.java:48)
    at net.cyan.arachne.PageServlet.doPost(PageServlet.java:32)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:713)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:462)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:387)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:315)
    at net.cyan.arachne.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:314)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.gzzm.platform.login.AuthorityFilter.doFilter(AuthorityFilter.java:87)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1627)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

解决方案:

 

根据类名来查找对应的表队列记录:

   select * from user_sequences where sequence_name=""

如果是国产数据库:因为国产那边,不能手动修改起始值,所以要把这条数据删除掉,再重新创建一条新记录,并把起始值改为查出来的值+1(select max(Id) from xxx)

如果是oracle,mysql数据库:直接查询出来,再把起始值改为查出来的值+1(select max(Id) from 表名)

  MySQL:select * from sequences where name like '表名%'  

Oracle:select * from user_sequences where sequence_name like "表名%"   

例如:

 

 

 

 

 

 

标签:core,catalina,java,解决方案,约束,apache,违反,org,ApplicationFilterChain
来源: https://www.cnblogs.com/chendezhen/p/16188889.html