SQL state [null]; error code [0]; ORA-00900: invalid SQL statement with jdbcTemplate

Pawan Patil :

I am facing exception while executing following query from jdbcTemplate

update TEMP_BRD_STATS SET STATS=null WHERE BRDC_STAT_ID=?

and following is the exception

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [update TEMP_BRD_STATS SET STATS=null WHERE BRDC_STAT_ID=?]; SQL state [null]; error code [0]; ORA-00900: invalid SQL statement

Where TEMP_BRD_STATS is my table name STATS and BRDC_STAT_ID are column in my table

Note : - null is allowed for STATS column

However I can successfully execute the query in sql developer by providing valid BRDC_STAT_ID column value.

e.g.

update TEMP_BRD_STATS SET STATS=null WHERE BRDC_STAT_ID=523;

Edit: Following is the JAVA code

result = this.jdbcTemplate.query("update TEMP_BRD_STATS SET STATS=null WHERE BRDC_STAT_ID=?",  new Object[] {523}, new QueryResultSetExtractor());

Column value is getting changed after executing above code although exception is thrown.

Suppose my column STATS is having 'SUCCESS' value and after executing above java code value is getting changed to null but still it is throwing exception. kind of weird scenario.

Joop Eggen :

The parameter ? evidently is not filled in. Maybe some parameter like:

new Object[] { brdStatId }

In general JDBC it could have been using not the PreparedStatement.executeUpdate() but the base class version Statement.executeUpdate(String sql).


After code added in question:

Ah, query (SELECT) and update (INSERT/UPDATE) mixed up:

this.jdbcTemplate.update("update TEMP_BRD_STATS SET STATS=null WHERE BRDC_STAT_ID=?", 523);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=90852&siteId=1