JDBC Interview Questions and Answers

11 Mar 2022, 22 Questions

It is the acronym for Java Database Connectivity providing Java application program interface allowing the access of RDBMS (Relational Database Management System) by the Java programs. The API consists of classes and interfaces enabling the implementation of the SQL statements by the java programs. Here you would find the top JDBC interview questions reading which help you more about the concept.

In the article below, you will come across the best JDBC Interview Questions, read them to help yourself ace the interview round and get the job of your dreams.

  • It eases enterprise development
  • Give existing enterprise data
  • No need for configuration for network computers
  • No need for installation
  • Have complete access to metadata

Most Frequently Asked JDBC Interview Questions

Here in this article, we will be listing frequently asked JDBC Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q1. What are JDBC and its components?

Java Database Connectivity with the acronym of JDBC is known as standard Java API. It is an interface for database-independent in between a broad range of databases and Java programming language. It allows the application programs for the interaction with the database for accessing the data.

Components of Java Database Connectivity are-
  • Driver
  • Connection
  • DriverManager
  • SQLException
  • Statement
  • ResultSet
1 0
Q2. Explain some new features available in JDBC 4.0?
  • Exception handling- In the new features of JDBC 4.0, there is an addition of the abilities to recover from the exceptions by including support for the chained exceptions. These are used for the retrieval of the chained exceptions.
  • Driver and connection management- DriverManager with the appropriate DataSource object gives way to the connection retrieval and allows the portability and transparency of the data source instance. There are no requirements of bringing any changes in the application code for building a connection to the different database instance.
  • Data type support- Additions of some new data types and the rise in the support for others is another unique feature of JDBC 4.0. Also, new features of the interface, SQLML are added.
  • Changes in API- Important and most required API changes have been done here in JDBC 4.0- Array, Connection and PooledConnection, DatabaseMetaData, Wrapper, Statement, PreparerdStatement, and CallableStatement, etc.
0 1
Q3. Why do we use JDBC in Java?

This java SE technology is used for building connecting java application with the database. It gets automatically installed with JDK software and used for the communication of Java application to the database in the platform and database independent manner.

0 1
Q4. Explain the necessary steps to connect to the database in Java?
  • Import JDBC packages and then load in any of the following ways- Class.forName(), DriverManager.registerDriver(). Then register JDBC driver
  • Open the connection to the database Connection con= DriverManager.getConnection (url, user, password)
  • To perform a query, create a statement object Statement st= con.createStatement ();
  • Implement the statement object and then return the query resultset. After that process it.
  • Close the resultset, statement objects, and the connection Con.close();
1 0
Q5. What are the different types of JDBC drivers?
The following are the types of JDBC drivers-
  • JDBC-ODBC bridge driver
  • Native-API Driver
  • All Java+ Middleware translation driver
  • Pure Java Driver
0 0
Q7. What is Drivermanager in JDBC?

DriveManager is a public class in JDBC which is used to extend the Objects classes. The set of JDBC drivers is managed by the essential services provided by DriverManager. The loading of the driver classes referenced in the jdbc.drivers is attempted by it.

0 0
Q8. What is the use of the statement in JDBC?

The two statements in JDBC, such as PreparedStatement, and CallableStatement are used for defining the properties and the methods for letting the user send PL/SQL or SQL commands. Also, receiving the data from the database and determining the methods for bridging the data type differences become comfortable with the statement interfaces.

0 0
Q9. What is a rollback in JDBC?

It is used for rolling back the transactions or committing them explicitly. It is like undoing the changes. An action can be rolled back to the same savepoint more than once.

0 0
Q11. What is the Execute method in Java?

The method is used for executing a query. It returns true if the ResultSet object is the query return. It returns one ResultSet object.


Int m = st.executeUpdate(sql);

If (m==1)

System.out.println (“inserted successfully: “+sql);


System.out.println (“insertion failed”);

0 0
Q12. What is transaction processing in JDBC?

In JDBC, carrying out of all the sets of actions in one go is known as a transaction. It is an atomic action in which either all are carried out, or none of them is carried out. Java Transaction API

0 0
Q13. What is Savepoint in JDBC?

It is the point to which the transaction gets rolled back without affecting the preceding work. The method which is used for setting a savepoint object within the current transaction is Connection.setSavepoint().

0 0
Q14. List the common JDBC exceptions ?
There are several JDBC exceptions such as
  • Java.sql.BatchUpdateException
  • java.sql.SQLException
  • java.sql.DataTruncation
  • java.sql.SQLWarning
0 0
Q15. Which package is used for JDBC application?

Package Javax.sql is used for JDBC application.

0 0
Q16. What is connection pooling and why it is used?

Connection pooling is a maintained cache of database connections which are kept to be used for the future use of the database requests arise. It helps in improving the performance of the commands to be executed in the database.

0 0
Q17. Explain the locking system in JDBC & its types?

The locks are the preventive software mechanism which the other users cannot use the data resource.

Types of locks are there-
  • Row and key locks
  • Page Locks
  • Table locks
  • Database locks
0 0
Q19. What is two-phase commit in the database?

It is a standardized protocol assuring the implementation of a database commit in such a situation where the commit operation has to be broken into 2 parts. Saving the changes in the database is called commit whereas, rollback is undoing the changes. In the first phase of the commit, data is written into the data records by the servers needing commit data to the log. In the next step, it begins after getting the successful message from the previous phase, and the particular object, i.e., the coordinator, sends a signal to each server with the instructions of the commit.

0 0
Q22. How many types of ResultSet are there in JDBC?
There are three types of ResultSet in JDBC, namely
  • Forward-only
  • Scroll-insensitive
  • Scroll-sensitive
0 0
About Best Interview Question
Best Interview Question
Technical Consultant

With our 10+ experience in PHP, MySQL, React, Python & more our technical consulting firm has received the privilege of working with top projects, 100 and still counting. Our team of 25+ is skilled in distinct programming languages such as Python, Java, React.js, Angular, Node.js, PHP, HTML, CSS, Designing, iOS and Android apps, Database, .net, QA, Digital Marketing and Govt. jobs, etc. We are helping 10+ companies in solving their technical problems. When not found coding, our technical consultants can be seen helping out others.