首页 > 其他 > 详细

Statement VS PrepareStatement

时间:2014-03-12 23:33:36      阅读:525      评论:0      收藏:0      [点我收藏+]

Many relation database handle a JDBC sql query in blew four steps:

1, parse the incoming sql

2, compile the sql

3, plan/ optimize the sql.

4, execute the sql and return data

A Statement will always procceed the four steps for each sql quer sent to the database. A PrepareStatement will pre-execute the steps 1-3.

Thus, when creating a PreparedStatement some pre-optimization is performed immediately. 

 

Another advantage of the PreparedStatement class is the ability to create an incomplete query and supply parameter values at execution time. This type of query is well suited for filtering queries which may differ in parameter value only: 

preparedStatement also will avoid some sql injection risk.

 

callablestatement extend the preparestatement, it can excute a procedure.

Statement VS PrepareStatement,布布扣,bubuko.com

Statement VS PrepareStatement

原文:http://www.cnblogs.com/zhonghan/p/3597262.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!