Question: In JDBC, which method is used to execute a SQL statement?
Options:
executeQuery()
runQuery()
executeSQL()
executeStatement()
Correct Answer: executeQuery()
Solution:
In JDBC, the method used to execute a SQL statement is \'executeQuery()\'.
In JDBC, which method is used to execute a SQL statement?
Practice Questions
Q1
In JDBC, which method is used to execute a SQL statement?
executeQuery()
runQuery()
executeSQL()
executeStatement()
Questions & Step-by-Step Solutions
In JDBC, which method is used to execute a SQL statement?
Correct Answer: executeQuery()
Step 1: Understand that JDBC stands for Java Database Connectivity, which is a Java API for connecting to databases.
Step 2: Know that to interact with a database, you need to execute SQL statements.
Step 3: Identify that there are different methods in JDBC for executing SQL statements, such as 'executeQuery()', 'executeUpdate()', and 'execute()'.
Step 4: Recognize that 'executeQuery()' is specifically used for executing SQL statements that return data, like SELECT queries.
Step 5: Conclude that if you want to execute a SQL statement in JDBC that retrieves data, you should use the 'executeQuery()' method.
JDBC Execution Methods – Understanding the different methods in JDBC for executing SQL statements, such as executeQuery(), executeUpdate(), and execute().
Soulshift Feedback×
On a scale of 0–10, how likely are you to recommend
The Soulshift Academy?