相对于Statement,PreparedStatement的优点

a、PreparedStatement有助于防止SQL注入,因为它会自动对特殊字符转义。     b、PreparedStatement可以用来进行动态查询。

c、PreparedStatement执行更快。尤其当你重用它或者使用它的拼量查询接口执行多条语句时。

d、使用PreparedStatement的setter方法更容易写出面向对象的代码,而Statement的话,我们得拼接字符串来生成查询语句。       如果参数太多了,字符串拼接看起来会非常丑陋并且容易出错。

原文地址:https://www.cnblogs.com/moranqingcheng/p/14246113.html