Tag: databases

Questions Related to databases

  1. No Rows retrieved

  2. 8 is displayed 20 times

  3. 8 is displayed 1 time

  4. error message


Correct Option: B

What is the use of reuse storage clause when used with truncate table statement?

  1. specifies that the empty space created by deleting the records must be retained for this table and should not be used by other tables

  2. specifies that the empty space created by deleting the records, can be used by other tables.

  3. specifies that this transaction can be rolled back later

  4. This clause cannot be used with truncate statement


Correct Option: A
  1. JDBC is an API to connect to relational-, object- and XML data sources

  2. JDBC stands for Java DataBase Connectivity

  3. JDBC is an API to access relational databases, spreadsheets and flat files

  4. JDBC is an API to bridge the object-relational mismatch between OO programs and relational


Correct Option: B,C
  1. java.jdbc and javax.jdbc

  2. java.jdbc and java.jdbc.sql

  3. java.sql and javax.sql

  4. java.rdb and javax.rdb


Correct Option: C
  1. Which type of driver provides JDBC access via one or more ODBC drivers?
  1. Type 1 driver

  2. Type 2 driver

  3. Type 3 driver

  4. Type 4 driver


Correct Option: A

5.Which type of Statements can execute parameterized queries?

  1. PreparedStatement

  2. ParameterizedStatement

  3. ParameterizedStatement and CallableStatement

  4. All kinds of Statements (i.e. which implement a sub interface of Statement)


Correct Option: A

AI Explanation

To answer this question, you need to understand the concept of parameterized queries and the different types of statements in Java.

A parameterized query is a SQL statement that allows you to pass parameters dynamically at runtime. This is useful when you want to execute the same query multiple times with different parameter values.

In Java, there are different types of statements that can be used to execute SQL queries. The options provided are:

A. PreparedStatement - This option is correct because a PreparedStatement is specifically designed to execute parameterized queries. It allows you to define placeholders (parameters) in the SQL statement and then set their values at runtime using methods like setString, setInt, etc.

B. ParameterizedStatement - This option is incorrect because there is no built-in interface or class in Java named ParameterizedStatement.

C. ParameterizedStatement and CallableStatement - This option is incorrect because while a CallableStatement can execute stored procedures with parameters, it is not specifically designed for executing parameterized queries. Therefore, only the PreparedStatement is the correct option.

D. All kinds of Statements (i.e. which implement a sub interface of Statement) - This option is incorrect because not all types of statements in Java can execute parameterized queries. Only the PreparedStatement is designed for this purpose.

Therefore, the correct answer is A) PreparedStatement.