EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

JDBC Interview Questions

By Priya PedamkarPriya Pedamkar

Home » Data Science » Data Science Tutorials » Database Management Tutorial » JDBC Interview Questions

JDBC interview questions

Introduction to JDBC Interview Questions and Answers

Java Database Connectivity (JDBC) is an API (Application Programming Interface) for the Java programming language. It is a data access technology to access and perform the database operations using Java programming language. It was developed by Oracle Corporation. It is a part of the Java Standard Edition (SE) platform. It is oriented with the relational database management system. It supports the cross-platform operating system. It is a kind of Data Access type of API. A JDBC API Guide will be provided by the Oracle Corporation to implement the JDBC features. JDBC connections will provide an interface to execute the queries for retrieving and updating the data from and to the database. There are different types of JDBC drivers such as Type 1, Type 2, Type 3, Type 4, etc. There will be also commercial and free drivers.

Below are the most important question asked in the interview:

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Now, if you are looking for a job which is related to JDBC then you need to prepare for the JDBC Interview Questions for 2021. It is true that every interview is different as per the different job profiles. Here, we have prepared the important JDBC Interview Questions and Answers for 2021 which will help you get success in your interview. These questions are divided into two parts are as follows:

Part 1 – JDBC Interview Questions (Basic)

This first part covers basic Interview Questions and Answers.

Q1. What is a JDBC?

Answer:
JDBC is a Java API library for establishing a connection between a database and a java application. The database will be normally a relational database management system. JDBC uses drivers to establish connection and JDBC library will be used to call the database connections. JDBC driver will be the interface between Java application and database. It provides connection to any kind of tabular data, especially relational or structural data.

Q2. What are the steps involved in making JDBC connectivity?

Answer:
This is the basic JDBC Interview Questions asked in an interview. The different steps in establishing a JDBC connection are –

  1. Loading Driver: This is the first step where a specific and suitable JDBC driver will be loaded to establish a communication with the database.
  2. Connection: This step will get the connection from the database using a connection object which will send the statements to execute the queries and will return the result objects where the result of the query will be stored.
  3. Create Statement: The statement object can be collected from Collection object to obtain the result from the database.
  4. Execute Query: The query can be executed using the statement object to query the database and retrieve the result.
  5. Close Connection: The database connection will be closed once after the result set is received from the database.

Q3. What are the different types of Statements in JDBC?

Answer:
There are different statements in the JDBC API to retrieve the result set based on different requirements. They are Statement, Prepared Statement, and Callable Statement :

Popular Course in this category
Sale
JDBC Training (6 Courses, 7+ Projects)6 Online Courses | 7 Hands-on Projects | 37+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (8,960 ratings)
Course Price

View Course

Related Courses
SQL Training Program (7 Courses, 8+ Projects)PL SQL Training (4 Courses, 2+ Projects)Oracle Training (14 Courses, 8+ Projects)
  • Statement: In this type of statement, the result set can be retrieved during the time of runtime and it does not require any parameters to be passed.

Example:-

Statement statementObject = conn.createStatement( );
ResultSet resultSetObject = stmt.executeQuery();

  • Prepared Statement: In this type of statement, the query can be executed as many times as needed or frequently whenever required in the application and it also allows in taking the parameters.

Example:-

String query = "Update Employee SET type= ? WHERE empId = ?"; PreparedStatement psObject = connObj.prepareStatement(query);
ResultSet rsObject = psObject.executeQuery();

  • Callable Statement: In this type of statement, the query can be executed using stored procedures and also takes parameters during runtime.

Example:-

CallableStatement csObject = connObject.prepareCall("{call EMPLOYEE_DETAILS}");
ResultSet rsObject = csObject.executeQuery();

Let us move to the next JDBC Interview Questions.

Q4. What are the different types of JDBC drivers?

Answer:
The below is the list of different JDBC drivers used to connect to the database. They are Type 1, Type 2, Type 3 and Type 4 drivers:

  1. Type 1: The Type 1 database is also called as JDBC – ODBC bridge driver. In this type, the ODBC driver will be used to establish a connection to the database.
  2. Type 2: The Type 2 database is also called as Native API or Partial Java JDBC driver. In this type, client-side libraries will be used by the driver to connect to the database.
  3. Type 3: The Type 3 database is also called as Network protocol Pure Java JDBC driver. In this type, application server acts as a middleware or interface which converts JDBC calls directly to the database calls.
  4. Type 4: The Type 4 database is also called Native Protocol Pure Java JDBC driver. In this type, thin driver exists which converts the database calls to vendor-specific database protocols to connect to the database.

Q5. What are the different JDBC components used?

Answer:
The different components used in the JDBC API to connect to the database are as below:

  1. PreparedStatement
  2. CallableStatement
  3. Query
  4. ResultSet
  5. ResultSetMetadata
  6. DatabaseMetadata
  7. Connection
  8. DriverManager

Note: – Metadata is data about the data.

Part 2 – JDBC Interview Questions (Advanced)

Let us now have a look at the advanced Interview Questions.

Q6. What are the different methods used to query the database?

Answer:
The different methods used to query the database are execute(), executeQuery() and executeUpdate().

  • execute(): This method is used to execute a query for any type of SQL statements. This return type is of Boolean i.e. true or false.
  • executeQuery(): This method is used to execute the queries such as an only SELECT type of statements. Its return type is of an object such as ResultSet object.
  • executeUpdate(): This method is used to execute the queries which perform operations such as INSERT, UPDATE, DELETE etc., Its return type is of integer i.e. 0 or 1.

Q7. What are the different types of locks in JDBC?

Answer:
This is the advanced Interview Questions asked in an interview. The different types of locks in JDBC are as below:

  1. Key and Row Locks
  2. Table Locks
  3. Page Locks
  4. Database Locks

Q8. What is a ResultSet?

Answer:
A ResultSet is an object which contains the data that is retrieved from the database using an SQL query. ResultSet always maintains a cursor that points to a row in the database table.

Q9. What is Connection Pooling in Database?

Answer:
The Connection Pooling in the database is the process of storing the connection in Cache which can be reused later. It provides faster connections and easier to troubleshoot the issues.

Q10. What are the different types of exceptions and errors in JDBC?

Answer:
The different types of exceptions while making a JDBC connection are as below:

  1. SQLException
  2. BatchUpdateException
  3. Data Truncation Error
  4. SQLWarning

Recommended Articles

This has been a guide to the list of JDBC Interview Questions and Answers so that the candidate can crackdown these Interview Questions easily. Here in this post, we have studied top JDBC Interview Questions which are often asked in interviews. You may also look at the following articles to learn more –

  1. Java Spring Interview Questions
  2. Java Testing Interview Questions
  3. JSP Interview Questions
  4. JSF Interview Questions

JDBC Training(6 Courses, 7+ Projects)

6 Online Courses

7 Hands-on Projects

37+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

2 Shares
Share
Tweet
Share
Primary Sidebar
Database Management Tutorial
  • DataBase Management
    • Text Data Mining
    • Roles of Database Management System in Industry
    • SQL Server Database Management Tools
    • Database administrator skills
    • Database Management Systems Advantages
    • Database Testing Interview Questions
    • Data Administrator
    • Database Administrator
    • Database Management Software
    • DataStage
    • Types of Database Models
    • Types of Database
    • Hierarchical Database Model
    • Relational Database
    • Relational Database Advantages
    • Operational Database
    • What is RDBMS?
    • What is DB2?
    • Data Masking Tools
    • Database Security
    • Data Replication
    • Bitmap Indexing
    • Second Normal Form
    • Third Normal Form
    • Fourth Normal Form
    • Data Definition Language
    • Data Manipulation Language
    • Data Control Language
    • Transaction Control Language
    • Conceptual Data Model
    • Entity-Relationship Model
    • Relational Database Model
    • Sequential File Organization
    • Checkpoint in DBMS
    • Teradata Create Table
    • Centralized Database
    • Data Storage in Database
    • Thomas write Rule
    • DBA Interview Questions
    • What is JDBC?
    • jdbc hive
    • Apriori Algorithm
    • JDBC Architecture
    • JDBC Interview Questions
    • Wildcard Characters
    • Distributed Database System
    • Multidimensional Database
  • PL/SQL
    • What is PL/SQL?
    • Careers in PL/SQL
    • PLSQL procedure
    • PL/SQL Exception
    • PL/SQL LIKE
    • PL/SQL Raise Exception
    • PLSQL rowtype
    • PLSQL? bind variables
    • PL/SQL Record
    • PL/SQL WITH
    • PL/SQL bulk collect
    • PL/SQL Block Structure
    • PL/SQL else if
    • PL/SQL nvl2
    • PL/SQL Package
    • PL/SQL exists
    • PL/SQL instr
    • PL/SQL listagg
    • PL/ SQL Formatter
    • PLSQLlength
    • PL/SQL Commands
    • PL/SQL Data Types
    • CASE statement in PL/SQL
    • PL/SQL IF Statement
    • Loops in PL/SQL
    • PL/SQL Add Column
    • For Loop in PLSQL
    • PL/SQL Cursor Loop
    • PLSQL Array
    • Cursors in PL/SQL
    • PL/SQL FOR Loop Cursor
    • PL/SQL Queries
    • PL/SQL SELECT INTO
    • PL/SQL TO_CHAR
    • PL/SQL UNION
    • PL/SQL NOT EQUAL
    • PL/SQL varray
    • PL/SQL Concatenate
    • PL/SQL UPDATE
    • PL/SQL TRIM
    • PL/SQL GROUP BY
    • PL/SQL GOTO
    • PL/SQL Date Functions
    • PL/ SQL having
    • PL/SQL to_DATE
    • PL/SQL NVL
    • PLSQL format date
    • PLSQL mod
    • PLSQL round
    • PL/SQL Boolean
    • PL/SQL exit
    • PL/SQL DECODE
    • PL/SQL ROWNUM
    • PLSQL?pivot
    • PLSQL string functions
    • PL/SQL Block
    • PL/SQL Function
    • PL/SQL Unwrapper
    • PL/SQL Table
    • PL/SQL ALTER TABLE
    • PLSQL execute immediate
    • Triggers in PL/SQL
    • PL/SQL Collections
    • PL/SQL stored procedure
    • PL/SQL Anonymous Block
    • PLSQL Interview Questions
  • TSQL Basic
    • TSQL
    • What is T-SQL
    • T-SQL Commands
    • T-SQL String Functions
    • TSQL Interview Questions
  • MariaDB
    • MariaDB Versions
    • MariaDB?list users
    • MariaDB Commands
    • MariaDB Server
    • MariaDB? Data Types
    • MariaDB?boolean
    • MariaDB phpMyAdmin
    • MariaDB Mysqldump
    • MariaDB Java Connector
    • MariaDB insert
    • MariaDB UPDATE
    • MariaDB? rename column
    • MariaDB AUTO_INCREMENT
    • MariaDB Timezone
    • MariaDB GROUP_CONCAT
    • MariaDB wait_timeout
    • MariaDB MaxScale
    • MariaDB? with
    • MariaDB? create?table
    • MariaDB? SHOW TABLES
    • MariaDB alter table
    • MariaDB List Tables
    • MariaDB JSON Functions
    • MariaDB Foreign Key
    • MariaDB? trigger
    • MariaDB Grant All Privileges
    • MariaDB Select Database
    • MariaDB? create database
    • MariaDB Delete Database
    • MariaDB List Databases
    • MariaDB Functions
    • MariaDB? TIMESTAMP
    • MariaDB create user
    • MariaDB add user
    • MariaDB show users
    • MariaDB Delete User
    • MariaDB? change user password
    • MariaDB? change root password
    • MariaDB reset root password
    • MariaDB IF
    • MariaDB bind-address
    • MariaDB Transaction
    • MariaDB Cluster
    • MariaDB Logs
    • MariaDB Encryption
    • MariaDB? backup
    • MariaDB Replication
    • MariaDB max_allowed_packet
    • MariaDB? performance tuning
    • MariaDB export database
    • MariaDB? import SQL
  • SQLite
    • What is SQLite
    • SQLite Commands
    • SQLite Data Types
    • SQLite COUNT
    • SQLite Boolean
    • SQLite autoincrement
    • SQLite select
    • SQLite? Bulk Insert
    • SQLite? add column
    • SQLite? concat
    • SQLite BETWEEN
    • SQLite group by
    • SQLite CASE
    • SQLite group_concat
    • SQLite array
    • SQLite? enum
    • SQLite sum
    • SQLite create table
    • SQLite Alter Table
    • SQLite Create Database
    • SQLite Delete
    • SQLite connection string
    • SQLite Database
    • SQLite Describe Table
    • SQLite Show Tables
    • SQLite exit
    • SQLite create index
    • SQLite foreign key
    • SQLite Stored Procedures
    • SQLite Extension
  • DB2
    • DB2? current date
    • DB2 purescale
    • DB2 backup
    • DB2 restore
    • DB2 C Express
    • DB2 Version
    • DB2? Architecture
    • DB2? Data Types
    • DB2? load
    • DB2? order by
    • DB2 date
    • DB2 NVL
    • DB2? update
    • DB2 warehouse
    • DB2 grant
    • DB2 database
    • DB2 VARCHAR
    • DB2? INSERT
    • DB2 LISTAGG
    • DB2 LIKE
    • DB2 TRUNCATE TABLE
    • DB2 LIST TABLES
    • DB2 between
    • DB2? current timestamp
    • DB2? length
    • DB2? bind
    • DB2 limit rows
    • DB2? export
    • DB2 with
    • DB2 Create Table
    • DB2 case statement
    • DB2 CAST
    • DB2 Functions
    • DB2 Date Functions
    • DB2? row_number
    • DB2 trim
    • DB2? Translate
    • DB2 UNION
    • DB2 timestamp
    • DB2? TIMESTAMPDIFF
    • DB2? replace
    • DB2 merge
    • DB2 COALESCE
    • DB2 ISNULL
    • DB2? explain
    • DB2 Join
    • DB2 alter column
    • DB2 rename column
    • DB2? Describe Table
    • DB2? rename table
    • DB2 List Databases
    • DB2 LUW
    • DB2 Query
    • DB2 GROUP BY
    • DB2 TO_DATE
    • View Serializability in DBMS
    • MariaDB Join
    • MariaDB JSON
    • MariaDB? show databases
    • Dataset Normalization
    • MariaDB Max Connections
    • jdbc connection
    • MariaDB GUI
  • DBMS
    • Introduction To DBMS
    • DBMS ER Diagram
    • What is DBMS?
    • DBMS Canonical Cover
    • DBMS Log-Based Recovery
    • DBMS Multivalued Dependency
    • Netezza Database
    • DBMS Concepts
    • DBMS Constraints
    • DBMS_Scheduler
    • B+ Tree in DBMS
    • DBMS_LOB
    • dbms entity
    • DBMS Foreign Key
    • DBMS Users
    • DBMS_Metadata.get_ddl
    • Relational Algebra in DBMS
    • DBMS Components
    • DBMS Features
    • DBMS Models
    • DBMS Relational Model
    • Hashing in DBMS
    • DBMS network model
    • Relationship in DBMS
    • ER Model in DBMS
    • Data Models in DBMS
    • Static Hashing in DBMS
    • Advantages of DBMS
    • dbms_output.put_line
    • DBMS Data Dictionary
    • dbms_xplan.display_cursor
    • Normal Forms in DBMS
    • DBMS helps achieve
    • DBMS 3 tier Architecture
    • Relational Calculus in DBMS
    • Serializability in DBMS
    • File Organization in DBMS
    • DBMS Transaction Processing
    • States of Transaction in DBMS
    • Functional Dependency in DBMS
    • Generalization in DBMS
    • Data Independence in DBMS
    • Lock Based Protocols in DBMS
    • Deadlock in DBMS
    • Integrity Constraints in DBMS
    • Concurrency Control in DBMS
    • Validation Based Protocol in DBMS
    • DBMS Locks
    • Normalization in DBMS
    • Transaction Property in DBMS
    • Specialization in DBMS
    • Aggregation in DBMS
    • Types of DBMS

Related Courses

SQL Certification Course

PL/SQL Certification Course

Oracle Certification Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Special Offer - JDBC Training(6 Courses, 7+ Projects) Learn More