Consider the following statement: prepStmt = dbConn.prepareStatement ("INSERT INTO MyTable (ID, FSTNAME, LSTNAME VALUES (?,?,?

Consider the following statement:
prepStmt = dbConn.prepareStatement (“INSERT
INTO MyTable
(ID, FSTNAME, LSTNAME
VALUES (?,?,?)”);
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 FSTNAME and
LSTNAME columns are VARCHAR data types. The value for the ? placeholders in the SQL
statement are held by member variables named id, fstName and IstName respectively. Which of
the following statements would properly execute the statement given in this question?

Consider the following statement:
prepStmt = dbConn.prepareStatement (“INSERT
INTO MyTable
(ID, FSTNAME, LSTNAME
VALUES (?,?,?)”);
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 FSTNAME and
LSTNAME columns are VARCHAR data types. The value for the ? placeholders in the SQL
statement are held by member variables named id, fstName and IstName respectively. Which of
the following statements would properly execute the statement given in this question?

A.
prepStmt.setlnteger (1, id);
prepStmt.setstring (2, fstName);
prepStmt.setString (3, IstName);
dbConn.executeUpdate (prepStmt);

B.
prepStmt.setlnteger (0, id);
prepStmt.setString (1, fstName);
prepStmt.setString (2, IstName);
prepStmt.executeUpdate ();

C.
prepStmt.setlnt(0, id);
prepStmt.setString (1, fstName);
prepStmt.setString (2, IstName);
dbConn.executeUpdate (prepStmt);

D.
prepStmt.setlnt (1, Id);
prepStmt.setString (2, fstName);
prepStmt.setString (3, IstName);
prepStmt.executeUpdate ();



Leave a Reply 0

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