SQL注入问题
SQL注入问题
1.statement不能防止SQL注入,preparedstatement可以防止SQL注入
2.常见sql注入,通过字符串拼接。为什么?因为sql是解释性语句,运行时,它的数据是由程序员的代码和用户提交的数据共同组成。
比如:代码是select *from user where username="123" and password =md5('123456')
当在用户名框输入('or 1=1#)【'是英文的】,这时密码就可随便输入,因为#在mysql中是注释符,当输入(' or 1=1#)时,
等价select *from user where username='' or 1=1# and password =md5('123456')
等价于select *from user where username='' or 1=1

浙公网安备 33010602011771号