Top 50+ Advanced Java JDBC Interview Questions 2019-2020 - 1

Question: 1

What is JDBC PreparedStatement?

JDBC PreparedStatement object represents a precompiled SQL statement.

We can use its setter method to set the variables for the query.

Since PreparedStatement is precompiled, it can then be used to efficiently execute this statement multiple times.

PreparedStatement is better choice that statement because it automatically escapes the special characters and avoid SQL injection attacks.

Question: 2

Briefly tell about the JDBC Architecture?

The JDBC Architecture consists of two layers

The JDBC API

The JDBC Driver API

The JDBC API provides the applications JDBC Manager connection.

The JDBC Driver API supports the JDBC Manager to Driver Connection.

The JDBC driver manager authenticate that the correct driver has been used to access each data source.

The JDBC Driver API interacts with a driver manager, database specific driver for providing transparent connectivity for the heterogeneous databases.

The driver manager supports multiple concurrent drivers connected to the multiple heterogeneous databases.

Question: 3

What are the flow statements of JDBC?

A URL string -- > getConnection -- > DriverManager -- > Driver -- > Connection -- > Statement -- > executeQuery -- > ResultSet.

Question: 4

What is connection pooling?

A connection pooling is a methodology of reusing open connections.

After finishing of a transaction the connection is not closed, but is put to the pool, and when a user requests a database connection the next time, he gets a pooled connection instead of a newly opened one.

This greatly reduces the time to perform single database operations, because of avoiding heavyweight open/close operations. It’s recommended to use database connection pooling as widely as possible.

Related Questions