Article From:

1、StatementWith a SQL statement, he executes a SQL generation execution plan. And PrepareStatement, he will precompile (of course, if your database supports these precompiling), when the same SQL statement (the parameters may be different), because he has done the pretext.Compiling (the SQL statement is compiled once before use, the database is caching), and when the same statement is executed later, he does not compile again, but matches directly from the cache. Statement is not like this. No matter what they are different, just execute SQL once.In a sentence, the database will be compiled once.

2、When many SQL statements are required to be executed, Statement will continue to compile, which will greatly consume system resources. PrepareStatement can be pre compiled and processed, and she does not need every SQL statement to be executed.Set the same parameters in the statement, change the SQL statement by changing the parameters, a bit like function, thus greatly improving the efficiency.

3、Reference website

Leave a Reply

Your email address will not be published. Required fields are marked *