003. Whatis the difference between statement and PreparedStatement?
First: preparestatement Initializes SQL first, submits the SQL to the database for preprocessing, and uses multiple times to improve efficiency. Save time and increase the readability of your code
Createstatement does not initialize, no preprocessing, no time is starting from 0 to execute SQL
Second: Preparestatement can replace variables, can be included in SQL statements, can be used Ps=conn.preparestatement ("select* from Cust where id=?"); and statement can't
Third:PreparedStatement faster than Statement ,preparedstatement can write dynamic parameterized query, when the database only perform one-time access, with Statement object for processing. The overhead of PreparedStatement objects is larger than statement, and there is no additional benefit for one-time operations.
Java Interview--02