Which of the following is NOT a valid method to execute an SQL query in JDBC?
A. `executeUpdate()`
B. `execute()`
C. `executeBatch()`
D. `executeQuery()`
Answer: Option C
Solution (By Examveda Team)
executeUpdate(): This method is used to execute SQL statements that update the database, such asINSERT, UPDATE, or DELETE statements. It returns an integer representing the number of rows affected by the query.execute(): This method can be used to execute any SQL statement, and it returns a boolean. The returned value is
true if the result is a ResultSet object; otherwise, it returns false.executeBatch(): This method is used to execute a batch of SQL statements. It sends multiple SQL statements to the database for execution as a batch and returns an array of update counts. It is not used to execute a single SQL query.
executeQuery(): This method is used to execute SQL queries that retrieve data from the database, such as
SELECT statements. It returns a ResultSet object containing the data produced by the query.Therefore, executeBatch() is not a valid method to execute a single SQL query in JDBC.
Join The Discussion
Comments (1)
A. A reusable software component that follows specific conventions
B. A type of coffee bean
C. A Java class used for file I/O
D. A Java keyword
Which file extension is commonly used for JavaBean files?
A. `.bean`
B. `.jar`
C. `.class`
D. `.java`
In JavaBeans, what is the purpose of the getter method?
A. To set the value of a property
B. To create a new instance of a bean
C. To retrieve the value of a property
D. To execute a SQL query
What is the role of the `javabeans.Introspector` class in JavaBeans?
A. It represents a JavaBean interface
B. It allows you to examine the properties, events, and methods of a bean
C. It handles database connections
D. None of These

The method executeBatch() is not typically used to execute SQL queries in JDBC; instead, it is used to execute batches of SQL statements. So, the answer is C. executeBatch().