SQL Injection PreparedStatement

Pubblicato il: 19 dicembre 2022
sul canale di: Antra Java SEP
513
4

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);
}
}


In questa pagina del sito puoi guardare il video online SQL Injection PreparedStatement della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Antra Java SEP 19 dicembre 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 513 volte e gli è piaciuto 4 spettatori. Buona visione!