当前位置: 代码迷 >> Oracle开发 >> 数据库主键摩擦
  详细解决方案

数据库主键摩擦

热度:126   发布时间:2016-04-24 06:29:21.0
数据库主键冲突
这个是我目前实习的系统的报错,有点不明白怎么看到底错误出在哪?因为目前还在学习,请教各位板块的伙伴看看。谢谢了
主键冲突异常 
详细信息 
[command]= (command ownerId="13541523" ownerName="core" poolName="core" startTime="2015-02-17 09:51:59.010" endTime="1970-01-01 08:00:00.000" cost="-1424137919010" correlation="0" beanClass="ep.boimpl.bssr.arcgp.OGPMeterImpl" beanMethod="put") (statement)(![CDATA[insert into C_METER(CONS_MT_ID, METER_ID, INST_LOC, INST_DATE, T_FACTOR, REF_METER_FLAG, REF_METER_ID, VALIDATE_CODE, MODULE_NO, ORG_NO, MR_FACTOR, LAST_CHK_DATE, ROTATE_CYCLE, ROTATE_VALID_DATE, SIM_CARD_NO, CHK_CYCLE, BIN_MT_POS, MADE_NO, ASSET_NO, BAR_CODE, COMM_ADDR1, COMM_ADDR2, COMM_NO, BAUDRATE, COMM_MODE, ATTACHEQUIP_TYPE_CODE, METER_KIND) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]])(/statement) (parameters) (parameter index="1") (value type="java.math.BigDecimal")(![CDATA[29199345]])(/value) (value type="java.math.BigDecimal")(![CDATA[8000000007226265]])(/value) (value type="java.lang.String")(![CDATA[电表箱内]])(/value) (value type="java.sql.Timestamp")(![CDATA[2015-02-16 15:16:56.0]])(/value) (value type="java.math.BigDecimal")(![CDATA[1]])(/value) (value type="java.lang.String")(![CDATA[0]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="java.lang.String")(![CDATA[3645514]])(/value) (value type="java.lang.String")(![CDATA[1]])(/value) (value type="java.sql.Timestamp")(![CDATA[2015-02-16 15:16:56.0]])(/value) (value type="java.math.BigDecimal")(![CDATA[120]])(/value) (value type="java.sql.Timestamp")(![CDATA[2025-02-16 15:16:56.0]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="java.lang.String")(![CDATA[140000051158]])(/value) (value type="java.lang.String")(![CDATA[3630001181400000511587]])(/value) (value type="java.lang.String")(![CDATA[3630001181400000511587]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="java.lang.String")(![CDATA[01]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (value type="{unknown}")(![CDATA[{null}]])(/value) (/parameter) (/parameters) (/command) [transaction]= (TransactionStatus id="25468198" beginPersistence="false" beginTransaction="false" rollbackOnly="true" hasPersistence="false") (Persistence id="13541523"/) (TransactionDefinition propagation="REQUIRED" method="ep.boimpl.bssr.arcgp.OGPMeterImpl.put" pool="core") (exceptions/) (/TransactionDefinition) (alterations/) (publish/) (/TransactionStatus) com.neusoft.persistence.exception.DataIntegrityViolationException: at com.neusoft.persistence.impl.dialect.SQLExceptionTranslator.assembleSQLException(SQLExceptionTranslator.java:82) at com.neusoft.persistence.impl.dialect.GenericDialect.assembleException(GenericDialect.java:717) at com.neusoft.persistence.impl.ExceptionCast.cast(ExceptionCast.java:21) at com.neusoft.persistence.impl.PersistenceImpl.doInsertRowSet(PersistenceImpl.java:741) at com.neusoft.persistence.impl.PersistenceImpl.updateRowSet(PersistenceImpl.java:665) at com.neusoft.persistence.impl.PersistenceImpl.update(PersistenceImpl.java:332) at com.neusoft.persistence.impl.PersistenceImpl.update(PersistenceImpl.java:315) at ep.boimpl.bssr.arcgp.OGPMeterImpl.put(OGPMeterImpl.java:343) at ep.boimpl.bssr.arcgp.OGPMeterImpl$$EnhancerByCGLIB$$b90e8165.CGLIB$put$0((generated)) at ep.boimpl.bssr.arcgp.OGPMeterImpl$$EnhancerByCGLIB$$b90e8165$$FastClassByCGLIB$$8e53b66.invoke((generated)) at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) at com.neusoft.bean.impl.TransactionInterceptor.intercept(TransactionInterceptor.java:124) at ep.boimpl.bssr.arcgp.OGPMeterImpl$$EnhancerByCGLIB$$b90e8165.put((generated)) at ep.boimpl.bssr.ArcGPImpl.put(ArcGPImpl.java:103) at ep.boimpl.bssr.ArcGPImpl$$EnhancerByCGLIB$$ec832982.CGLIB$put$1((generated)) at ep.boimpl.bssr.ArcGPImpl$$EnhancerByCGLIB$$ec832982$$FastClassByCGLIB$$d74eb85.invoke((generated)) at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) at com.neusoft.bean.impl.TransactionInterceptor.intercept(TransactionInterceptor.java:124) at ep.boimpl.bssr.ArcGPImpl$$EnhancerByCGLIB$$ec832982.put((generated)) at ep.boimpl.bssr.ArcGPImpl.put(ArcGPImpl.java:243) at ep.boimpl.bssr.ArcGPImpl$$EnhancerByCGLIB$$ec832982.CGLIB$put$3((generated)) at ep.boimpl.bssr.ArcGPImpl$$EnhancerByCGLIB$$ec832982$$FastClassByCGLIB$$d74eb85.invoke((generated)) at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) at com.neusoft.bean.impl.TransactionInterceptor.intercept(TransactionInterceptor.java:124) at ep.boimpl.bssr.ArcGPImpl$$EnhancerByCGLIB$$ec832982.put((generated)) at ep.boimpl.bssp.ArchiveImpl.doSubmit(ArchiveImpl.java:290) at ep.boimpl.bssp.ArchiveImpl$$EnhancerByCGLIB$$76980d19.CGLIB$doSubmit$2((generated)) at ep.boimpl.bssp.ArchiveImpl$$EnhancerByCGLIB$$76980d19$$FastClassByCGLIB$$ce3aaa60.invoke((generated)) at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) at com.neusoft.bean.impl.TransactionInterceptor.intercept(TransactionInterceptor.java:124) at ep.boimpl.bssp.ArchiveImpl$$EnhancerByCGLIB$$76980d19.doSubmit((generated)) at ep.boimpl.bssp.ArchiveAndFinishImpl.doSubmit(ArchiveAndFinishImpl.java:42) at ep.boimpl.bssp.ArchiveAndFinishImpl$$EnhancerByCGLIB$$b7e5be27.CGLIB$doSubmit$0((generated)) at ep.boimpl.bssp.ArchiveAndFinishImpl$$EnhancerByCGLIB$$b7e5be27$$FastClassByCGLIB$$9879af69.invoke((generated)) at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) at com.neusoft.bean.impl.TransactionInterceptor.intercept(TransactionInterceptor.java:124) at ep.boimpl.bssp.ArchiveAndFinishImpl$$EnhancerByCGLIB$$b7e5be27.doSubmit((generated)) at ep.component.core.NavigationController.subCommit(NavigationController.java:592) at ep.component.core.NavigationController.commit(NavigationController.java:806) at ep.component.core.NavigationController$$EnhancerByCGLIB$$69a47cd2.CGLIB$commit$2((generated)) at ep.component.core.NavigationController$$EnhancerByCGLIB$$69a47cd2$$FastClassByCGLIB$$c26173cb.invoke((generated)) at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215) at com.neusoft.bean.impl.TransactionInterceptor.intercept(TransactionInterceptor.java:90) at ep.component.core.NavigationController$$EnhancerByCGLIB$$69a47cd2.commit((generated)) at sun.reflect.GeneratedMethodAccessor520.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.neusoft.component.ComponentServlet.execute(ComponentServlet.java:203) at com.neusoft.component.ComponentServlet.doPost(ComponentServlet.java:101) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.neusoft.commons.web.filter.EncodingFilter.doFilter(EncodingFilter.java:38) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3242) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2010) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1916) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) Caused by: java.sql.SQLException: ORA-00001: 违反唯一约束条件 (EPM_JX.PK_METER_ID) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454) at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:128) at com.neusoft.persistence.impl.Executor.updateOne(Executor.java:279) at com.neusoft.persistence.impl.Executor.update(Executor.java:258) at com.neusoft.persistence.impl.PersistenceImpl.doInsertRowSet(PersistenceImpl.java:732) ... 62 more  
系统报错如上面,不知道怎么看是哪张表报错了? 冲突的字段是哪个也不清楚,希望有人回复。新年快乐,谢谢!
   
------解决思路----------------------
你检查一下向这个表C_METER中插入的数据和表里已存在的数据是否有(主键)重复的。

------解决思路----------------------
引用:
Quote: 引用:

你检查一下向这个表C_METER中插入的数据和表里已存在的数据是否有(主键)重复的。
查出重复,我是不是需要删除掉那条重复记录?或者说使用update更新下主键的数据呢?

对的,你可以更新或者删除,具体的操作根据你的实际业务而定
------解决思路----------------------
引用:
Quote: 引用:

你检查一下向这个表C_METER中插入的数据和表里已存在的数据是否有(主键)重复的。
查出重复,我是不是需要删除掉那条重复记录?或者说使用update更新下主键的数据呢?

就像5楼说的,根据你的实际业务来判断,是数据的问题,还是数据库表(主键)设计的问题。
------解决思路----------------------
提示很明确啊,ORA-00001: 违反唯一约束条件 (EPM_JX.PK_METER_ID) 
看看这个EPM_JX.PK_METER_ID的定义,你插入的数据按此主键,已经存在同样的数据了
  相关解决方案