插入时出现 ORA-04043

我们正在尝试存储一条记录:


DSLContext dsl = DSL.using(conn, SQLDialect.ORACLE12C);

KampartikelRecord kampartikelRecord = dsl.newRecord(KAMPARTIKEL);

kampartikelRecord.setKampagne(387);

kampartikelRecord.setArtnr("090248");

kampartikelRecord.setArtId(5558);

kampartikelRecord.store();

但我们得到:


org.jooq.exception.DataAccessException: SQL [insert into "TOSCA"."KAMPARTIKEL" ("KAMPAGNE", "ART_ID", "ARTNR") values (?, ?, ?)]; ORA-04043: Objekt "TOSCA" ist nicht vorhanden

    at org.jooq_3.12.1.ORACLE12C.debug(Unknown Source)

    at org.jooq.impl.Tools.translate(Tools.java:2717)

    at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)

    at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:383)

    at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:206)

    at org.jooq.impl.TableRecordImpl$1.operate(TableRecordImpl.java:177)

    at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:130)

    at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:173)

    at org.jooq.impl.UpdatableRecordImpl.store0(UpdatableRecordImpl.java:196)

    at org.jooq.impl.UpdatableRecordImpl$1.operate(UpdatableRecordImpl.java:136)

    at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:130)

    at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:132)

    at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:124)

    at ch.tosca.common.repository.JooqRepositoryTest.insertKampartikel(JooqRepositoryTest.java:66)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   ... 48 more

我读过有关驱动程序不兼容的 GitHub 问题,但数据库和驱动程序 ojdbc8 都是版本 12.2.0.1.0


我们做错了什么?


开心每一天1111
浏览 165回答 1
1回答

呼啦一阵风

以下是使用普通 JDBC 重现它的方法:如何重现它使用此表CREATE TABLE T (  ID NUMBER(7),  CONSTRAINT pk PRIMARY KEY (ID));在内部使用Connection.prepareStatement(String, String[])重载,例如 jOOQ 所做的:try (Connection c = dbSetup.getConnection()) {    try (PreparedStatement s = c.prepareStatement(        "insert into \"TEST\".\"T\" (\"ID\") values (?)", new String[] { "ID" })) {        s.setInt(1, 1);        s.execute ();    }}解决方法不要引用架构名称:try (Connection c = dbSetup.getConnection()) {    try (PreparedStatement s = c.prepareStatement(        "insert into TEST.\"T\" (\"ID\") values (?)", new String[] { "ID" })) {        s.setInt(1, 1);        s.execute ();    }}完全避免资格:try (Connection c = dbSetup.getConnection()) {    try (PreparedStatement s = c.prepareStatement(        "insert into \"T\" (\"ID\") values (?)", new String[] { "ID" })) {        s.setInt(1, 1);        s.execute ();    }}使用 jOOQ 中的解决方法:您可以使用关闭模式限定Settings.renderSchema您可以使用关闭标识符的引用Settings.renderQuotedNames
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java