JAVA JDBC Programming Interview Preparation Guide
Download PDF

JAVA JDBC Programming Interview Questions and Answers will teach us now that how to use Java JDBC, so learn JDBC with the help of this JDBC Interview Questions with Answers guide

19 JDBC Questions and Answers:

1 :: What is JDBC?

JDBC is a layer of abstraction that allows users to choose between databases. It allows you to change to a different database engine and to write to a single API. JDBC allows you to write database applications in Java without having to concern yourself with the underlying details of a particular database.

2 :: What are the two major components of JDBC?

One implementation interface for database manufacturers, the other implementation interface for application and applet writers.

3 :: What is JDBC Driver interface?

The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendors driver must provide implementations of the java.sql.Connection,Statement,PreparedStatement, CallableStatement, ResultSet and Driver.

4 :: What are the common tasks of JDBC?

1.Create an instance of a JDBC driver or load JDBC drivers through jdbc.drivers;
2. Register a driver;
3. Specify a database;
4. Open a database connection;
5. Submit a query;
6. Receive results.

5 :: What packages are used by JDBC?

There are 8 packages: java.sql.Driver, Connection,Statement, PreparedStatement, CallableStatement, ResultSet, ResultSetMetaData, DatabaseMetaData.

6 :: What are the flow statements of JDBC?

A URL string

7 :: What are the steps involved in establishing a connection using JDBC in JAVA?

This involves two steps:
(1) loading the driver and
(2) making the connection.

8 :: How can you load the drivers in JDBC?

Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:
Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ , you would load the driver with the following line of code:


9 :: What Class.forName will do while loading drivers of JDBC?

It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

10 :: How can you make the connection using JDBC?

In establishing a connection is to have the appropriate driver connect to the DBMS. The following line of code illustrates the general idea:

String url = “jdbc:odbc:Fred”;
Connection con = DriverManager.getConnection(url, “Fernanda”, “J8”);