Ask Question

Suppose a prepared statement is created as follows.

PreparedStatement ps = conn. prepareStatement

("insert into Student (fName, mi, lName) values (?,?,?) ");

To assign the value John to the first parameter of this query, use

ps. setString (1, "John");.

ps. set (1, "John");.

ps. setString (0, "John");.

ps. set (0, "John");.

+4
Answers (1)
  1. 14 July, 17:18
    0
    The correct answer for the given question is ps. setString (1, "John");.

    Explanation:

    Prepared statement are used in java programming language. Prepared statement are the interface they increases the performance i. e query run faster.

    According to the question we have to assign the value of first parameter i. e "fName" as "fname" is a string that means we have to set a string parameter so following query will be used ps. setString (1, "John");. This statement specify the first parameter in the query. The setString () method set the string along with the position and the value of string. If we have to set integer parameter then we have to use "setInt () " along with position and the value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Suppose a prepared statement is created as follows. PreparedStatement ps = conn. prepareStatement ("insert into Student (fName, mi, lName) ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers