JDBC Interview Questions and Answers
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.
Advantages
- 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
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);
Else
System.out.println (“insertion failed”);
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
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().
There are several JDBC exceptions such as
- Java.sql.BatchUpdateException
- java.sql.SQLException
- java.sql.DataTruncation
- java.sql.SQLWarning
Package Javax.sql is used for JDBC application.
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.
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
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.