<<< JDBC Interview Questions and Answers >>>





JDBC - Questions & Answers

Here is the list of JDBC Interview Questions. The answers are short and to the point.These questions are frequently asked by the recruiters. So we try our best to provide you the JDBC interview questions. A list of frequently asked JDBC interview questions and answers are given below.

«« | 1 2 3 | »»

JDBC: Java Interview Questions

1) What is JDBC?

Ans :JDBC is a Java API that is used to connect and execute query to the database. JDBC API uses jdbc drivers to connects to the database.


2) What is JDBC Driver?

Ans : JDBC Driver is a software component that enables java application to interact with the database.


3) What are the main steps in java to make JDBC connectivity?

Ans : Servlets can be created using :

  1. Registering the driver class
  2. Creating connection
  3. Creating statement
  4. Executing queries
  5. Closing connection

Registering the driver class :First step is to load the database specific driver which communicates with database.

Creating connection :Next step is get connection from the database using connection object, which is used to send SQL statement also and get result back from the database.

Creating statement :From connection object we can get statement object which is used to query the database

Executing queries :Using statement object we execute the SQL or database query and get result set from the query.

Closing connection :After getting resultset and all required operation performed the last step should be closing the database connection.


4) What are different types of JDBC Drivers?

Ans : There are four types of drivers defined by JDBC as follows: :

  1. JDBC/ODBC
  2. Native API
  3. Network Protocol Driver
  4. ative Protocol Drive


5) What is the use of JDBC DriverManager class?

Ans :The DriverManager class manages the registered drivers. It can be used to register and unregister drivers. It provides factory method that returns the instance of Connection.


6) What are the types of statements in JDBC?

Ans :There are 3 JDBC statements.

  1. Statement
  2. PreparedStatement
  3. CallableStatement


7) What is JDBC Statement?

Ans :JDBC Statement is used to run simple SQL statements like select and update. Statement interfaces use for general-purpose access to your database. It is useful when you are using static SQL statements at runtime. The Statement interface cannot accept parameters.


8) What is JDBC PreparedStatement?

Ans : A SQL statement is pre-compiled and stored in a Prepared Statement object. It is used to run Pre compiled SQL. This object can then be used to efficiently execute this statement multiple times. The object of Prepared Statement class can be created using Connection.prepareStatement() method. This extends Statement interface.


9) What is JDBC Callable Statement?

Ans : This interface is used to execute the stored procedures. This extends Prepared Statement interface. The object of Callable Statement class can be created using Connection.prepareCall() method.


10) What is Stored Procedures?

Ans : Stored Procedures is a group of SQL statements that form a logical unit and perform particular task.


«« | 1 2 3 | »»