Skip to Main Content
  • Questions
  • java.sql.SQLException: SQL string is not Query - While updating BLOB column

Breadcrumb

May 4th

Question and Answer

Connor McDonald

Thanks for the question, Rajendra.

Asked: December 20, 2018 - 5:22 pm UTC

Last updated: December 24, 2018 - 1:46 am UTC

Version: Oracle 12c

Viewed 1000+ times

You Asked

Greetings:

We are facing below exception, while executing a query "UPDATE TRN_WSF_SERVICE_AUDIT SET REQUEST=EMPTY_CLOB() WHERE TRN_WSF_SERVICE_AUDIT_SID = 75002202" here REQUEST is a CLOB datatype.

Detailed error
-------------------------------------------------------------------------
java.sql.SQLException: SQL string is not Query
                at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1176)
                at oracle.jdbc.driver.OracleStatement.doScrollExecuteCommon(OracleStatement.java:4767)
                at oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:4895)
                at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1399)

and Connor said...

An update is not a query.

Don't use "executeQuery", just use executeUpdate

eg

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();
        }


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here