标签:varchar res 查询 sele 成功 失败 ati sql注入 lan
insert into login values(1,’abc’,’123’);
insert into login values(2,’abcd’,’1234’);
select * from login where name=’abc’ and pwd=’123’
select * from login where name=’abc’or’1==1’ and pwd=’123dhdhdhdhdhd’
select * from login where name= ‘abc\’or\’1==1’ and pwd= ‘123dhdhdhdhdhd’
public static void loginIn(String name, String pwd) throws Exception {
DriverManager.registerDriver(new Driver());
Connection conn = DriverManager.getConnection("jdbc:mysql://**.***.**.***:3306/ngyb", "root", "123456");
String sql = "select * from login where name = ? and pwd =?";
PreparedStatement prepareStatement = conn.prepareStatement(sql);
prepareStatement.setString(1, name);
prepareStatement.setString(2, pwd);
ResultSet resultSet = prepareStatement.executeQuery();
if (resultSet.next()) {
System.out.println("登录成功");
} else {
System.out.println("登录失败");
}
resultSet.close();
prepareStatement.close();
conn.close();
}
}
标签:varchar res 查询 sele 成功 失败 ati sql注入 lan
原文地址:https://www.cnblogs.com/nangongyibin/p/10200572.html