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);
}
}
Sur cette page du site, vous pouvez voir la vidéo en ligne SQL Injection PreparedStatement durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Antra Java SEP 19 décembre 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 513 fois et il a aimé 4 téléspectateurs. Bon visionnage!