SQL注入(PreparedStatement)
来源:互联网 发布:人工智能可以思考吗 编辑:程序博客网 时间:2024/05/18 01:59
public class Demo2 { //private String name = "ericdfdfdfddfd' OR 1=1 -- "; private String name= "ericdfdfdfddfd' OR 1=1 -- "; private String password="123456"; @Test public void test1(){ Connection conn=null; Statement stmt=null; ResultSet rs=null; try { conn=JdbcUtil.getConnection(); String sql="select * from users where name='"+name+"' and password='"+password+"'"; stmt = conn.createStatement(); rs=stmt.executeQuery(sql); if(rs.next()){ System.out.println("登录成功!"); }else{ System.out.println("登录失败!"); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); }finally{ JdbcUtil.close(stmt, conn,rs); } } @Test public void test2(){ Connection conn=null; PreparedStatement stmt=null; ResultSet rs=null; try { conn=JdbcUtil.getConnection(); String sql="select * from users where name=? and password=?"; stmt=conn.prepareStatement(sql); stmt.setString(1, name); stmt.setString(2, password); rs = stmt.executeQuery(); if(rs.next()){ System.out.println("登录成功!"); }else{ System.out.println("登录失败!"); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); }finally{ JdbcUtil.close(stmt, conn,rs); } }}
0 0
- SQL注入(PreparedStatement)
- JDBC(四)SQL 注入与 PreparedStatement
- PreparedStatement 防止sql注入
- JDBC(PreparedStatement,sql注入)
- 使用PreparedStatement防止SQL注入
- 验证preparedStatement防止SQL注入
- 使用PreparedStatement防止SQL注入
- 使用PreparedStatement防止SQL注入
- 使用PreparedStatement防止SQL注入
- jdbc防止sql注入-PreparedStatement
- 使用PreparedStatement防止SQL注入
- jdbc防止sql注入-PreparedStatement
- 使用PreparedStatement防止SQL注入
- sql注入的问题,PreparedStatement
- 使用PreparedStatement防止SQL注入
- SQL注入与PreparedStatement接口
- 验证preparedStatement防止SQL注入
- PreparedStatement防止SQL注入小记
- SpringMVC详细示例实战教程
- 选择法排序
- 用keytool创建Keystore和Trustsotre文件
- 信息
- IOS数据库操作SQLite3使用详解
- SQL注入(PreparedStatement)
- 应知道的数据库连接池DBCP配置及JDBC超时设置
- mongo中删除filed不存在的document
- 冒泡
- 如何把PDF文件内容转换成TXT
- 华为C语言编程规范—排版
- 登陆界面
- IPC网络高清摄像机基础知识5(经典YUV格式详解)
- 16进制