Javatpoint Logo

91-9990449935

 0120-4256464

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.

more details...

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)
more details...

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

  • Registering the driver class
  • Creating connection
  • Creating statement
  • Executing queries
  • Closing connection
more details...

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.

more details...

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.

more details...

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.

more details...

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.

more details...

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.

more details...

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.

more details...

13) Which interface is responsible for transaction management in JDBC?

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

more details...

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.

more details...

15) How can we store and retrieve images from the database?

By using PreparedStatement interface, we can store and retrieve images.

more details...

1 2 3 4 5 6 7 8