Question: For which value of name will this code result in a successful SQL injection attack? A. DELETE TABLE records; B. 'Olivia'; DELETE TABLE records C.

For which value of name will this code result in a successful SQL injection attack? 

public Integer getScore (String connectionStr, String name) throws SQLException { } var

A. DELETE TABLE records;

B. 'Olivia'; DELETE TABLE records

C. 'Sophia; DELETE TABLE records

D. 'Elysia'; DELETE TABLE records

E. ?; DELETE TABLE records;
F. None of the above.

public Integer getScore (String connectionStr, String name) throws SQLException { } var query = "SELECT score FROM records WHERE name = ?"; var con Driver Manager.getConnection (connectionStr); try (con; var stmt = con.prepareStatement (query)) { stmt.setString(1, name); try (var rs = stmt.executeQuery()) { if(rs.next()) return rs.getInt("score"); } } return null;

Step by Step Solution

3.34 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet provided is using a PreparedStatement for executing the SQL query which is designed ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Oracle Questions!