出现异常 ORA-00942: 表或视图不存在 - 插入现有表时 [英] Getting an exception ORA-00942: table or view does not exist - when inserting into an existing table

查看:41
本文介绍了出现异常 ORA-00942: 表或视图不存在 - 插入现有表时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试向现有表中插入一批行时遇到异常

<块引用>

ORA-00942: 表或视图不存在

我可以确认该表存在于 db 中,并且我可以使用 oracle 向该表插入数据sql 开发人员.但是当我尝试在java中使用preparedstatement插入行时,它的抛出表不存在错误.

请在下面找到错误的堆栈跟踪

java.sql.SQLException: ORA-00942: 表或视图不存在在 oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)在 oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)在 oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)在 oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1889)在 oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)在 oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)在 oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)在 oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout>>(OracleStatement.java:2709)在 oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)在quotecopy.DbConnection.insertIntoDestinationDb(DbConnection.java:591)在quotecopy.QuoteCopier.main(QuoteCopier.java:72)

谁能提出这个错误的原因?

更新:问题已解决

我的数据库连接属性或者我的表或视图名称没有问题.问题的解决方法很奇怪.我尝试插入的列之一是 Clob 类型.由于我之前在 oracle db 中处理 clob 数据时遇到了很多麻烦,因此尝试将 clob setter 替换为临时字符串 setter,然后执行相同的代码没有任何问题,并且所有行都已正确插入!!!.<块引用>

即.peparedstatement.setClob(columnIndex, clob)

被替换为

<块引用>

peparedstatement.setString(columnIndex, "String")

为什么错误表或视图确实存在错误是因为插入 clob 数据时出错.谁能解释一下?

非常感谢您的回答和评论.

解决方案

我的数据库连接属性或者我的表或视图名称没有问题.问题的解决方法很奇怪.我尝试插入的列之一是 Clob 类型.由于我之前在 oracle db 中处理 clob 数据时遇到了很多麻烦,因此尝试将 clob setter 替换为临时字符串 setter,然后执行相同的代码没有任何问题,并且所有行都已正确插入!!!.<块引用>

即.peparedstatement.setClob(columnIndex, clob)

被替换为

<块引用>

peparedstatement.setString(columnIndex, "String")

I am getting below exception, when trying to insert a batch of rows to an existing table

ORA-00942: table or view does not exist

I can confirm that the table exists in db and I can insert data to that table using oracle sql developer. But when I try to insert rows using preparedstatement in java, its throwing table does not exist error.

Please find the stack trace of error below

java.sql.SQLException: ORA-00942: table or view does not exist

    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289) 
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573) 
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1889)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940) 
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout>>(OracleStatement.java:2709)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    at quotecopy.DbConnection.insertIntoDestinationDb(DbConnection.java:591)
    at quotecopy.QuoteCopier.main(QuoteCopier.java:72) 

Can anyone suggest the reasons for this error ?

Update : Issue solved

There was no problem with my database connection properties or with my table or view name. The solution to the problem was very strange. One of the columns that I was trying insert was of Clob type. As I had a lot of trouble handling clob data in oracle db before, gave a try by replacing the clob setter with a temporary string setter and the same code executed with out any problems and all the rows were correctly inserted!!!.

ie. peparedstatement.setClob(columnIndex, clob)

was replaced with

peparedstatement.setString(columnIndex, "String")

Why an error table or view does exist error was throws for error in inserting clob data. Could anyone of you please explain ?

Thanks a lot for your answers and comments.

解决方案

There was no problem with my database connection properties or with my table or view name. The solution to the problem was very strange. One of the columns that I was trying insert was of Clob type. As I had a lot of trouble handling clob data in oracle db before, gave a try by replacing the clob setter with a temporary string setter and the same code executed with out any problems and all the rows were correctly inserted!!!.

ie. peparedstatement.setClob(columnIndex, clob)

was replaced with

peparedstatement.setString(columnIndex, "String")

这篇关于出现异常 ORA-00942: 表或视图不存在 - 插入现有表时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆