There's lots of Q&A as to when and why it's better to use a PreparedStatement over a Statement in JDBC but not for the opposite? In other words when and why is it better to use Statement over PreparedStament? I'm struggling to find a use case where this is better. I've seen some comments that seem to indicate that in some cases it's better performance wise, but again it quickly goes back to PreparedStatement. So when is it better to use a Statement over a PreparedStatement?
As in:
connection.createStatement().executeQuery(sql);
vs
PreparedStatement preparedStatement = connection.preparedStatement(sql);
preparedStatement.execute();
With whatever additional code is needed.