Tuesday, August 20, 2002 02:19 PM
If you are referring to Statement
's ("createStatement") and PreparedStatement
's, the answer is in almost every situation that PreparedStatement
behaves better regarding performance.
This is due to the nature of PreparedStatement's: they are pre-compiled and reused by the JDBC driver. When you're using Connection.createStatement(), you are creating a new object for each SQL statement.
The biggest gap comes in situations where a similar SQL statement is executed several times in a row (as in a batch of statements) for the reasons mentioned above.
You could probably find several articles discussing the pro's and con's of using PreparedStatement vs. Statement around the Internet...
It's too late where I'm living, so please correct my half-a-sleep errors :)