PreparedStatement
is a slightly more powerful version of a Statement
, and should always be at least as quick and easy to handle as a Statement
. - Parse the incoming SQL query
- Compile the SQL query
- Plan/optimize the data acquisition path
- Execute the optimized query / acquire and return data
Statement
will always proceed through the four steps above for each SQL query sent to the database. A PreparedStatement
pre-executes steps (1) - (3) in the execution process above. Thus, when creating a PreparedStatement
some pre-optimization is performed immediately. The effect is to lessen the load on the database engine at execution time.The other strength of the PreparedStatement is that you can use it over and over again with new parameter values, rather than having to create a new Statement object for each new set of parameters. This approach is obviously more efficient, as only one object is created.
Use the set methods each time to specify new parameter values.
Where will be the pre executed steps stored, i.e) in Application server or in DataBaseServer
No comments:
Post a Comment