Getting an exception ORA-00942: table or view does not exist - when inserting into an existing table

前端 未结 10 1396
[愿得一人]
[愿得一人] 2020-11-28 15:17

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

<
10条回答
  •  天涯浪人
    2020-11-28 15:37

    I found how to solve this problem without using JDBC's setString() method which limits the data to 4K.

    What you need to do is to use preparedStatement.setClob(int parameterIndex, Reader reader). At least this is what that worked for me. Thought Oracle drivers converts data to character stream to insert, seems like not. Or something specific causing an error.

    Using a characterStream seems to work for me. I am reading tables from one db and writing to another one using jdbc. And i was getting table not found error just like it is mentioned above. So this is how i solved the problem:

    case Types.CLOB:   //Using a switch statement for all columns, this is for CLOB columns
            Clob clobData = resultSet.getClob(columnIndex); // The source db
            if (clobData != null) {
                preparedStatement.setClob(columnIndex, clobData.getCharacterStream());
            } else {
                preparedStatement.setClob(columnIndex, clobData);
            }
            clobData = null;
            return;
    

    All good now.

提交回复
热议问题