JSP网页防止sql注入攻击
来源:互联网 发布:梦幻西游mac更新错误 编辑:程序博客网 时间:2024/05/11 03:29
SQL注入攻击指的是通过构建特殊的输入作为参数传入Web应用程序,而这些输入大都是SQL语法里的一些组合,通过执行SQL语句进而执行攻击者所要的操作,其主要原因是程序没有细致地过滤用户输入的数据,致使非法数据侵入系统。
prepareStatement方法是防止sql注入的简单有效手段
preparedStatement和statement的区别
1、preparedStatement是statement的子方法
2、preparedStatement可以防止sql注入的问题
3、preparedStatement它可以对它所代表的sql语句进行预编译,以减轻服务器压力
实例如下:
public User find(String username, String password) {Connection conn = null;PreparedStatement st = null;ResultSet rs = null;try{conn = JdbcUtils.getConnection();String sql = "select * from users where username=? and password=?";st = conn.prepareStatement(sql); st.setString(1, username);st.setString(2, password);rs = st.executeQuery(); //if(rs.next()){User user = new User();user.setId(rs.getString("id"));user.setUsername(rs.getString("username"));user.setPassword(rs.getString("password"));user.setEmail(rs.getString("email"));user.setBirthday(rs.getDate("birthday"));return user;}return null;}catch (Exception e) {throw new DaoException(e);}finally{JdbcUtils.release(conn, st, rs);}}
0 0
- JSP网页防止sql注入攻击
- SQL注入防止攻击
- 防止sql注入攻击
- 防止SQL注入攻击
- 防止SQL注入攻击
- 防止SQL注入攻击
- 防止sql注入攻击
- 防止SQL注入攻击
- 防止SQL注入攻击
- 防止SQL注入攻击
- 防止sql注入式攻击
- 防止SQL注入式攻击
- 防止SQL注入式攻击
- 防止SQL注入式攻击
- 防止sql注入式攻击
- 防止SQL注入式攻击
- 防止SQL注入式攻击
- 防止SQL注入式攻击
- Eclipse的open in Explorer插件安装
- 黑马程序员-----------------面向对象_初识类与对象
- 黑马程序员_.Net设计模式之简单工厂设计模式
- stm32之CAN(二)
- 大数加法
- JSP网页防止sql注入攻击
- 求数组的子数组之和的最大值
- Windows 2012 R2中安装SharePoint 2013 sp1参考
- android动画
- .9图片的制作(draw9patch.bat工具的使用)
- Java之美[从菜鸟到高手演变]之设计模式 二
- android进程间通信:使用AIDL
- C++ 私有成员变量的理解
- 二叉查找树(二叉排序树)的详细实现