Question: What will this code do ? Connection conn = DriverManager.getConnection ( jdbc:mysql: / / localhost / library , user, pass ) ; PreparedStatement

What will this code do?
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/library", "user", "pass");
PreparedStatement ps = conn.prepareStatement("DELETE FROM books WHERE id =?");
ps.setInt(1,10);
int rowsAffected = ps.executeUpdate();
System.out.println(rowsAffected);
a.
Does nothing since executeQuery() is missing.
b.
Prints the number of rows affected.
c.
Deletes the book with id =10.
d.
Throws a SQL syntax error. it is possible to choice more than one

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!