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.
No concepts available.