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);
}
}
En esta página del sitio puede ver el video en línea SQL Injection PreparedStatement de Duración hora minuto segunda en buena calidad , que subió el usuario Antra Java SEP 19 diciembre 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 513 veces y le gustó 4 a los espectadores. Disfruta viendo!