Prepared statement cannot be executed after an exception

Details

Detail name Value
Changelog Number 5842
Type Bug
Status Resolved
Affected Versions Exasol 7.1.0, Exasol 8.0.0
Fix Versions Exasol 2026.1.0
Resolution Date 2026-05-15

Problem
The execution of a prepared statement leads to an internal server error if a previous execution of the same statement leads to an exception.

Since further executions of the statement are not allowed in this case the exception "Execution of prepared statement not allowed after exception!" should be returned.

Example
In the example

PreparedStatement ps = connection.prepareStatement("SELECT 1/? FROM DUAL;");

try {
    ps.setInt(1, 0); 
    ResultSet r1 = ps.executeQuery();
} catch(Exception e) {}

ps.setInt(1, 1);
ResultSet r2 = ps.executeQuery();

the first execution with the parameter value 0 leads to a data exception. The second execution with the parameter value 1 leads to an internal server error.

Workaround
The execution of a prepared statement after an exception can be avoided by creating a new prepared statement with identical SQL.