黑马程序员技术交流社区
标题:
jdbc 注入攻击问题
[打印本页]
作者:
feimingxuan
时间:
2016-6-15 01:20
标题:
jdbc 注入攻击问题
public class Demo_14 {
public static void main(String[] args) throws Exception {
DriverManager.registerDriver(new Driver());
Connection con = DriverManager.getConnection(
"jdbc:mysql://127.0.0.1:3306/dbl", "root", "123456");
String sql = "SELECT*FROM user WHERE usename=? and root = ?;";
PreparedStatement pst = con.prepareStatement(sql);
Scanner sc = new Scanner(System.in);
System.out.println("请输入用户名");
String usename = sc.nextLine();
System.out.println("请输入密码");
String root = sc.nextLine();
pst.setString(1, usename);
pst.setString(2, root);
ResultSet result = pst.executeQuery();
if (result.next()) {
System.out.println("登陆成功");
} else {
System.out.println("登陆失败");
}
result.close();
con.close();
pst.close();
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2