java.sql.SQLException: ORA-02291: integrity constraint violated - par

ORA-02291错误解决
本文详细解析了ORA-02291错误的原因及解决方案,该错误通常出现在尝试插入不存在父记录的子记录时。文章指导如何通过添加父记录或删除外键来解决问题,并介绍了主键和外键的概念。

java.sql.SQLException: ORA-02291: integrity constraint (BOOKER.FK_ANDON_EVENT_STATUS) violated - parent key not found

 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:743)
        at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
        at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
        at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)

原因:http://www.dba-oracle.com/t_ora_02291_integrity_constraint_string_string_violated_parent_key_not_found.htm

The Oracle docs note this on the ora-02291 error:

 ORA-02291: integrity constraint (string.string) violated - parent key not found

 
Cause: A foreign key value has no matching primary key value.
 

Action: Delete the foreign key or add a matching primary key.

For an insert statement, this ORA-02291 error is common when you are trying to insert a child without a matching parent, as defined by a foreign key constraint.  In that case, you need to add the parent row to the table and then re-insert your child table row.

See the dba_constraints view to find the parent table.

To fully understand [primary and foreign key constraints, see the book Easy Oracle Jumpstart, to explain these concepts:


实体完整性错误
你的外键FK_ANDON_EVENT_STATUS中对应的父表的列中没有相关数据就会出这错,应该先插入父表,再插子表

表a有一外键,指向表b,那么b就是a的parent table,外键所指的列就是parent key


2025-11-25 10:15:48.784 ERROR 5216 --- [Longshare-IO-Scheduler0] c.l.d.i.s.handler.AbstractRdfImpHandler : 读取文件数据出错! java.util.concurrent.CompletionException: https://example.org/problems/database_link_error{500, database_link_error, ORA-00001: unique constraint (ZGTA.UI_INCOME_INTERCEPTION_LOG) violated , timestamp=1764036948782} at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) ~[na:1.8.0_372] at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) ~[na:1.8.0_372] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1606) ~[na:1.8.0_372] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_372] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_372] at java.lang.Thread.run(Thread.java:750) [na:1.8.0_372] Caused by: org.zalando.problem.DefaultProblem: database_link_error: ORA-00001: unique constraint (ZGTA.UI_INCOME_INTERCEPTION_LOG) violated at org.zalando.problem.ProblemBuilder.build(ProblemBuilder.java:83) ~[problem-0.20.3.jar!/:na] at com.longshare.datasource.io.support.util.JdbcUtils.batchInsert(JdbcUtils.java:390) ~[io-support-202503.14-SNAPSHOT.jar!/:na] at com.longshare.datasource.io.support.handler.AbstractRdfImpHandler.lambda$importFile$0(AbstractRdfImpHandler.java:331) ~[io-support-202503.14-SNAPSHOT.jar!/:na] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604) ~[na:1.8.0_372] ... 3 common frames omitted 什么意思
最新发布
11-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值