0% found this document useful (0 votes)
46 views4 pages

JDBC Interview Question

The document discusses frequently asked JDBC interview questions and answers. It first defines JDBC as a Java API used to connect to and execute queries on a database using JDBC drivers. It then discusses the different types of JDBC drivers, the steps to connect to a database in Java, and the main JDBC API components like Connection, Statement, PreparedStatement, and ResultSet interfaces. Finally, it covers additional questions about JDBC statements, the differences between Statement and PreparedStatement, how to execute stored procedures, the role of the DriverManager class, and how to perform batch processing and store/retrieve images using JDBC.

Uploaded by

rishabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views4 pages

JDBC Interview Question

The document discusses frequently asked JDBC interview questions and answers. It first defines JDBC as a Java API used to connect to and execute queries on a database using JDBC drivers. It then discusses the different types of JDBC drivers, the steps to connect to a database in Java, and the main JDBC API components like Connection, Statement, PreparedStatement, and ResultSet interfaces. Finally, it covers additional questions about JDBC statements, the differences between Statement and PreparedStatement, how to execute stored procedures, the role of the DriverManager class, and how to perform batch processing and store/retrieve images using JDBC.

Uploaded by

rishabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

JDBC Interview Questions

A list of frequently asked jdbc interview questions with answers are given below.

1) What is JDBC?
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?


JDBC Driver is a software component that enables java application to interact with the
database. There are 4 types of JDBC drivers:
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)

3) What are the steps to connect to the database in java?

Registering the driver class

Creating connection

Creating statement

Executing queries

Closing connection

4) What are the JDBC API components?


The java.sql package contains interfaces and classes for JDBC API.
Interfaces:

Connection

Statement

PreparedStatement

ResultSet

ResultSetMetaData

DatabaseMetaData

CallableStatement etc.

Classes:

DriverManager

Blob

Clob

Types

SQLException etc.

5) What are the JDBC statements?


There are 3 JDBC statements.
1. Statement
2. PreparedStatement
3. CallableStatement

6) What is the difference between Statement and


PreparedStatement interface?
In case of Statement, query is complied each time whereas in case of PreparedStatement,
query is complied only once. So performance of PreparedStatement is better than
Statement.

7) How can we execute stored procedures and functions?


By using Callable statement interface, we can execute procedures and functions.

8) What is the role of JDBC DriverManager class?


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.

9) What does the JDBC Connection interface?


The Connection interface maintains a session with the database. It can be used for
transaction management. It provides factory methods that returns the instance of
Statement, PreparedStatement, CallableStatement and DatabaseMetaData.

10) What does the JDBC ResultSet interface?


The ResultSet object represents a row of a table. It can be used to change the cursor
pointer and get the information from the database.

11) What does the JDBC ResultSetMetaData interface?


The ResultSetMetaData interface returns the information of table such as total number of
columns, column name, column type etc.

12) What does the JDBC DatabaseMetaData interface?


The DatabaseMetaData interface returns the information of the database such as username,
driver name, driver version, number of tables, number of views etc.

13) Which interface is responsible for transaction management in


JDBC?
The Connection interface provides methods for transaction management such as
commit(), rollback() etc.

14) What is batch processing and how to perform batch


processing in JDBC?
By using batch processing technique in JDBC, we can execute multiple queries. It makes the
performance fast.

15) How can we store and retrieve images from the database?
By using PreparedStatement interface, we can store and retrieve images.

You might also like