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.
- 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
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-
- 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.
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.
- 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();
The following are the types of JDBC drivers-
- JDBC-ODBC bridge driver
- Native-API Driver
- All Java+ Middleware translation driver
- Pure Java Driver
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.
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.
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.