我们什么时候去Statement或PreparedStatement? [英] When do we go for Statement or PreparedStatement?

查看:184
本文介绍了我们什么时候去Statement或PreparedStatement?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

声明和PreparedStatement之间的差异

我们什么时候去Statement或PreparedStatement?

when do we go for Statement or PreparedStatement?

推荐答案

只有在查询中没有用户输入参数的情况下,才能使用Statement。否则,请使用PreparedStatement,因为它提供了避免sql注入的机制。 Wiki在描述其机制时良好

you can use Statement only in case if you have no user-input parameters in your query. Otherwise, use PreparedStatement as it provides the mechanism to avoid sql-injections. Wiki is good at describing the mechanisms of it.

这篇关于我们什么时候去Statement或PreparedStatement?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆