public static void main(String[] args) throws SQLException {
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/sep_training", "sep_user", "aabbccdd");
Statement statement = connection.createStatement();
String p = "3 or 1=1";
ResultSet rs = statement.executeQuery("select * from dish where id = " + p);
while (rs.next()) {
String name = rs.getString(2);
String c = rs.getString(3);
float price = rs.getFloat("price");
System.out.println(name + " - " + c + " - " + price);
}
System.out.println("/////");
PreparedStatement ps = connection.prepareStatement("select * from dish where id = ?");
ps.setInt(1, 3);
ResultSet rs1 = ps.executeQuery();
while (rs1.next()) {
String name = rs1.getString(2);
String c = rs1.getString(3);
float price = rs1.getFloat("price");
System.out.println(name + " - " + c + " - " + price);
}
}
On this page of the site you can watch the video online SQL Injection PreparedStatement with a duration of hours minute second in good quality, which was uploaded by the user Antra Java SEP 19 December 2022, share the link with friends and acquaintances, this video has already been watched 513 times on youtube and it was liked by 4 viewers. Enjoy your viewing!