码迷,mamicode.com
首页 > 其他好文 > 详细

A prepared statement is generated from a nonconsta

时间:2014-10-16 13:07:22      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:des   style   color   io   ar   java   sp   on   cti   

Findbugs报错:

A prepared statement is generated from a nonconstant String


The code creates an SQL prepared statement from a nonconstant String. If unchecked, tainted data from a user is used in building this String, SQL injection could be used to make the prepared statement do something unexpected and undesirable.


修改方法:
java.sql.PreparedStatement如果含有变量,改成?,然后用setString、setInt等方法替代。例如

            prepareStatement = conn.prepareStatement("insert into tableName (id,name) values (?,?)");

            prepareStatement.setString(1, value1);

            prepareStatement.setString(2, value2);


A prepared statement is generated from a nonconsta

标签:des   style   color   io   ar   java   sp   on   cti   

原文地址:http://my.oschina.net/ydsakyclguozi/blog/332799

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!