WHERE ID = ?

Consider the following statement:
prepStmt = dbConn.prepareStatement (” DELETE
FROM MyTable
WHERE ID = ?”);

The prepStmt member is of type PreparedStatement. The dbConn member is of type Connection
and represents a connection to a database. The ID column is an int data type. The value for the ?
placeholder in the SQL statement is held by a member variable named id. The id member’s value
was acquired via a getPhmaryKey() method. Which of the following statements would properly
execute the statement given in this question?

Consider the following statement:
prepStmt = dbConn.prepareStatement (” DELETE
FROM MyTable
WHERE ID = ?”);

The prepStmt member is of type PreparedStatement. The dbConn member is of type Connection
and represents a connection to a database. The ID column is an int data type. The value for the ?
placeholder in the SQL statement is held by a member variable named id. The id member’s value
was acquired via a getPhmaryKey() method. Which of the following statements would properly
execute the statement given in this question?

A.
prepstmt.setlnt (1, id.intValue ());
prepStmt.executeUpdate ();

B.
prepStmt.setlnteger (0, id.intValue ());
prepStmt.executeUpdate (prepStmt);

C.
prepStmt.setlnteger (0, id.intValue ());
prepStmt.executeUpdate ();

D.
prepstmt.setlnt (1, id.intValue ());
prepStmt.executeUpdate (prepStmt);



Leave a Reply 0

Your email address will not be published. Required fields are marked *