Are there any drawbacks to using Preparedstatement compared to Statement

I looked at the differences between Statement and PreparedStatement in JDBC and saw so many advantages here and here with PreparedStatement compared to Statement.

Some of my colleagues asked why we still need an expression and why it is not out of date, looking at the benefits of PreparedStatement.

So, is there a reason we still have a Statement in the JDBC API?

+6
source share
2 answers

PreparedStatement used to process dynamic SQL queries, where Statement used to process static SQL queries.

+2
source

So, is there a reason we still have a Statement in the JDBC API?

Yes, because it is in the SQL client-server API. If unprepared statements must be removed, then the JDBC function will be absent.

As pointed out in other answers, PreparedStatement has no advantages if there are no dynamic parameters. In these cases, the use of an unprepared operator is somewhat more concise.

The completely unanswered question is that PreparedStatement is the Suberinterface of the Statement statement, and therefore the latter cannot be deleted without redefining the API. This is more related to the Java API, although not related to SQL.

0
source

All Articles