0

我有一个有效的 dbconnection(JDBC、Oracle),并且大多数请求都可以正常工作,尤其是一些 Prepared Batched Statements。我有一个带有主键
的现有数据库。 testdb MESSID

使用语句(未准备好)stm时,以下工作正常:

stm.addBatch("insert into testdb (\"MESSID\",\"METAFID\",\"POSITIONSNUMMER\") select case when count(*)=0 then 1 else 1+max(messid) end,HEXTORAW(''3637534FD7ED259449DBF86E2A283890''),1 from testdb");
stm.addBatch("insert into testdb (\"MESSID\",\"METAFID\",\"POSITIONSNUMMER\") select case when count(*)=0 then 1 else 1+max(messid) end,HEXTORAW(''A17F5E246F1E44D78228C39274E226B2''),2 from testdb");
stm.addBatch();
stm.executeBatch()

当对preparedCalls(PreparedStatements,插入“METAFID”,“POSITIONSNUMMER”和set ...)做同样的事情时,这些查询在做.executeBatch.
我不确定,但在想,select case when count(*)=0 then 1 else 1+max(messid)片段出了问题(java.sql.BatchUpdateException: ORA-00001: Unique Constraint (????.testdb))。
谁能帮助或讲述自己的经历?

4

0 回答 0