Breaking News
Home / Java / Java Issues / java.sql.SQLException: ORA-00936: missing expression

java.sql.SQLException: ORA-00936: missing expression

JDBC Missing Expression

JDBC is very straightforward, create a sql and execute it. The sql created can be static or dynamic and based on the business logic the sql can be be complicated as well. In case of Oracle being used as a database, Oracle provided a unique error code that helps to narrow down the issue quickly. Lets look at one such error code

ORA-00936: missing expression<!>

Issue

The following exception can be seen in the logs with a very specific ORA code as show below:

java.sql.SQLException: ORA-00936: missing expression
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
        at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
        at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
        at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
        at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:894)
        at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:984)
        at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2885)
        at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2926)
        at com.p6spy.engine.logging.P6LogPreparedStatement.executeQuery(P6LogPreparedStatement.java:172)
        at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:124)

Resolution

Basically in the case a required part of a where clause or an expression has been omitted/missing for the sql and Oracle

For example, a SELECT statement passed on to the JDBC may be

– without a list of columns or 
– expressions or
– with an incomplete expression.

This error can also occur if any SQL reserved word is used.

So check the sql in code, sometimes the sql is created dynamically so closely review code to find out what is missing and try. If you can find the actual sql try execute from a SQL Client like SQL Developer at times it would give the location of the error in sql. If you are using P6SpyLog Driver then you can get the actual sql that is executed from the p6spy log file.

[pb_builder]

Check Also

Data truncation: Data too long for column – JDBC

Issue Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘columname‘ at row 1     …

Advertisment ad adsense adlogger