暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle java.sql.SQLException: 更新BLOB列时,SQL字符串不是查询

ASKTOM 2018-12-20
416

问题描述

问候:

在执行查询 “更新TRN_WSF_SERVICE_AUDIT SET REQUEST = EMPTY_CLOB() 其中TRN_WSF_SERVICE_AUDIT_SID = 75002202” 时,我们面临以下异常。这里的请求是CLOB数据类型。

详细错误
-
java.sql.SQLException: SQL字符串不查询
在oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1176)
在oracle.jdbc.driver.OracleStatement.doScrollExecuteCommon(OracleStatement.java:4767)
在oracle.jdbc.driver.OracleStatement.Docrollstmtexecutequery (OracleStatement.java:4895)
在cucutequery (OracleStatement.java:1399)

专家解答

更新不是查询。

不要使用 “executeQuery”,只需使用executeUpdate

例如

String updateStatement =
        "update MY_TABLE" +
        "set COL = COL + ? " +
        "where BLAH = ?";

    try {
        con.setAutoCommit(false);
        updateTotal = con.prepareStatement(updateStatement);

            updateTotal.setInt(1, ...);
            updateTotal.setString(2, ...);
            updateTotal.executeUpdate();
            con.commit();
        }
复制

文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论