PreparedStatement 比statement要安全些,尽量注意sql的编写,可以很好的sql的注入。

解决方案 »

  1.   

    PreparedStatement 比statement要安全些,
    如果别人知道你的数据库表就可以这样操作(数据库名:datastu)
    String sname="hh ' drop database datastu'";
    statement----sql="select * from stu where sname='"+sname+"'
    而如果用PreparedStatement就不会发生这样的情况。。
      

  2.   

    sql注入之前 先把字符过滤。
    就可以保证安全了。!~
      

  3.   

    我抓取的数据里包括 item name, categry, customer_id几个字段,都是文本的. 如果过滤敏感词汇我怕把正常信息也过滤掉. 那帮xx网上起的名字真的很乱,保不准就有起个delete drop啥的.... 有招么
      

  4.   

    做测试遇到过sql注入的问题,PreparedStatement 比statement,也可以在传入参数时先把某些字符串过滤掉。也在学习中,,,关注
      

  5.   

    PreparedStatement 比statement要安全些,
    如果别人知道你的数据库表就可以这样操作(数据库名:datastu)
    String sname="hh ' drop database datastu'";
    statement----sql="select * from stu where sname='"+sname+"'
    而如果用PreparedStatement就不会发生这样的情况。。
     
     
      

  6.   

    用参数化sql语句或存储过程可有效地防止sql注入攻击
      

  7.   

    PreparedStatement 比statement要安全些,如果允许,还是用hibernate之类的框架来完成,把注入的可能降低。
      

  8.   

    首先检测页面出现的SQL语句,还有过滤字符比如ibatis里的$符号
      

  9.   

    后台过滤SQL 关键字,如:create ,drop .......字符串操作而已。
      

  10.   

    把那些东西先用某种规则转换下,比如BASE64,这样就可以了