我们什么时候去Statement或PreparedStatement? [英] When do we go for Statement or PreparedStatement?
本文介绍了我们什么时候去Statement或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屋!
查看全文