
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialProgramming
4.7 Rating 60 Questions 29 mins read3 Readers

Here, JDBC stands for Java Database Connectivity. It is also known as Application Programming Interface. It is a Java API, which is used to connect and execute queries to the database. JDBC API uses JDBC drivers to connect to the database. JDBC is mainly used with relational database or SQL database like MySQL, Oracle, MS Access etc., we cannot use JDBC drivers with NoSQL or non-relational databases. Because JDBC API is mainly used to access tabular data stored into the relational databases
This is one of the most frequently asked JDBC interview questions for freshers in recent times.
To interact with any of the database JDBC uses JDBC drivers. JDBC drivers are the software components which enable Java applications to interact with Database.
There are mainly 4 types of JDBC drivers:
This is one of the most frequently asked JDBC interview questions for freshers in recent times.
The code to connect Java and MySQL database is as follows.
try {
Class.forName ("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection ("jdbc: mysql://localhost:3306/dbanme", "username", "password");
Statement st=con.createstatement ();
Resultset rs=st.executeQuery ("select * from user");
rs.next ();
} catch (ClassNotFoundException e) {
System.err.println("ClassNotFoundException in get Connection," + e.getMessage());
}catch (SQLException e) {
System.err.println ("SQLException in getConnection," + e.getMessage ());
}
Code to connect Java and Oracle database.
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection con= DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:dbname", "username", "password");
Statement st=con.createstatement();
Resultset rs=st.executeQuery("select * from user");
rs.next();
} catch (ClassNotFoundException e) {
System.err.println("ClassNotFoundException in get Connection," +e.getMessage());
} catch (SQLException e) {
System.err.println("SQLException in getConnection, " + e.getMessage());
}
return con;
}
Explanation:
The Class.forName is used to create instance of JDBC driver using DriverManager.
The getConnection() of DriverManager is used to create connection to the database.
Then we must create a Statement object using the connection object. The statement object will return the resultSet Object. The ResultSet.next() means the ResultSet is still returning the row.
Expect to come across this, one of the most important JDBC interview questions for experienced professionals in Java, in your next interviews.
There are mainly 4 types of JDBC API components.
A. JDBC API: The JDBC API provides various interfaces and methods to establish connection with different types of databases. These connecting methods will be present in different package, some of them are
javax.sql.*; java.sql.*;
B. JDBC Driver Manager: The JDBC Driver Manager loads the database-specific driver into the application, to establish connection with the database. The JDBC Driver manager is also used to call databases to do the processing of user requests.
C. JDBC Test Suite: The JDBC test suite provides required facilities to the application developer to test various functionalities like updating, deletion, insertion which are executed by the JDBC drivers.
D. JDBC-ODBC Bridge: The JDBC-ODBC Bridge is used to connect the database drivers to the database. It converts JDBC method calls into ODBC method calls. It uses a package sun.jdbc.odbc provide access the ODBC (Open Database Connectivity) characteristics using native libraries
In JDBC, there are set of Statements, which are used to send SQL commands to the relational database and receive data from it. The JDBC statements provides several types of methods such as executeUpdate(), execute(), executeQuery() and many more, which helps to interact with the database to send and receive data.
There are three types of JDBC statements.
Statement: Statement is known as the factory for resultSet. It is used for common interaction with the database. It executes static structured queries at run time.
Statement st = conn.createStatement( ); ResultSet rs = st.executeQuery();
String SQL = "Update item SET limit = ? WHERE itemType = ?"; PreparedStatement ps = conn.prepareStatement(SQL); ResultSet rs = ps.executeQuery();
CallableStatement cs = con.prepareCall("{call SHOW_CUSTOMERS}"); ResultSet rs = cs.executeQuery();
Batch processing is the process in which we will be executing multiple SQL statements at a time or in one transaction. For example, consider a case of loading data from CSV file, CSV files are nothing but Comma Separated Files). So here, we are loading these CSV files to database tables. To store the data into database earlier we used to call Statement or PreparedStatement but it is time consuming. In these cases, we can go for Batch Processing method. Batch processing executes the bulk of queries in single go for a database.
Advantages of Batch Processing:
To perform batch processing, we should use addBatch() and executeBatch() methods. These two methods are available in the Statement and PreparedStatement classes of JDBC API. By using these methods in the JDBC connection we can execute set of queries in one go.
One of the most frequently posed Java Database Connectivity questions and answers, be ready for this conceptual question.
Getter methods: The getter methods are used for retrieving the particular column values of the table from the ResultSet. It expects column index or column name as a parameter. The getter method is represented as getXXX() method.
Example: int getInteger (String columnName)
The above example is used to retrieve the value of the specified column index and the return type is an int datatype.
Setter methods: The setter methods are used to set the value in the database. It is similar to the getter methods, but it requires a value to be passed for the particular column to insert that value into the database. Setter methods are represented as setXXX() method.
Example: void setInt(int Column_Index, int Data_Value)
The above statement is used to insert the value of the specified column Index with an int value.
Connection pooling is a database connection mechanism where the data will be stored in the cache so the data can be reused if it is required in the future. So it is not required to make new connection every time for interacting with database. Because the connection objects are stored in connection pool so the client can get connection object from there.
Advantages of using connection pool:
Locking system for a user means when multiple users accessing the same application and trying to update or adding the record into the database at the same time, in such situation we are going to lock so that the data will not be lost.
There are two types of locking available in JDBC:
This is a common yet one of the most important JDBC interview questions and answers for experienced professionals, don't miss this one. Here are the definitions.
One of the most frequently posed Java Database Connectivity questions and answers, be ready for this conceptual question.
JDBC connection is a connection connecting JDBC application into the database using driver classes provided by JDBC.
There are mainly 5 steps to connect any Java application to the database using JDBC. They are as follows.
Step 1: Register the Driver Class:
The forName() method of the Class is used to register to the Driver Class. This method loads the driver class dynamically. Since after the JDBC update to JDBC 4 registering the driver class is optional. We just must put the jar in the classpath so the JDBC driver manager will detect and load the driver automatically.
Syntax:
public static void forName(String className)throws ClassNotFoundException
Example:
Class.forName("oracle.jdbc.driver.OracleDriver");
Step 2: Create the Connection Object:
For creating connection to the database, we use getConnection() of DriverManager class, it establishes connection to the database.
Syntax:
throws SQLException
Example:
Connection con = DriverManager.getConnection ( "jdbc:oracle:thin:@localhost:1521:xe","system","password");
Step 3: Create the Statement object:
The statement object is used to execute queries with the database. We use createStatement() method of Connection interface. The statement object executes queries with the database.
Syntax:
public Statement createStatement()throws SQLException
Example:
Statement stmt=con.createStatement();Step 4: Execute Query
The executeQuery() method is also from the Statement Interface. It is used to execute queries to the database. It returns the object of ResultSet, which is used to get all the records of a table.
Syntax:
public ResultSet executeQuery(String sql)throws SQLException
Example:
ResultSet rs=stmt.executeQuery("select * from emp"); while(rs.next()){ System.out.println(rs.getInt(1)+" "+rs.getString(2)); }
Step 5: Close the Connection object:
If we close the connection object of statement then ResultSet object will be closed automatically. The close() method of connection interface is used to close the JDBC database connection.
Syntax:
Public void close()throws SQLException
Example:
con.close(); The architecture of JDBC includes, the application layer, the JDBC API layer, driver manager layer and the JDBC driver layer.
The application layer: The Application layer is a Java based servlet or applet-based application which contains data-sources and database management information.
The JDBC API layer: The JDBC API layer allows the application developer to run the Java programs to perform the execution of the SQL statements to get the expected output. Some of the widely used interfaces and classes present in JDBC API are:
The DriverManager layer: The DriverManager layer plays an important role in the application development and database connectivity. It uses database specific drivers to connect the Java enterprise application to different of databases.
JDBC drivers’ layer: The JDBC drivers acts the bridge between the application layer and the driver manager. It interacts with the data sources with the help of JDBC. And it interacts with respective drivers to provide specific application needs.
One of the most frequently posed Java Database Connectivity questions and answers, be ready for this conceptual question.
The architecture of the JDBC supports two 2 types of processing models, they are:
a. Two-tier architecture:
In two-tier architecture JDBC application interacts directly with the data source. The Java application programs interact directly with no third-party mediation. There is no requirement for mediators like application servers to connect with JDBC API drivers. The Two-tier architecture is also called client-server architecture. When a query is sent by the user to the data source, the response will be sent back directly to the user.
b. Three-tier architecture:
In Three-tier architecture, the interaction between Java application and Database will happen via middle-tier services. It is completely opposite to the Two-tier architecture. It will make an application server as a mediator to communicate between JDBC drivers or Java application and database.
The sequence execution of SQL statements served as a single unit is called Transaction. Transaction Management plays an important role in RDBMS applications to maintain data consistency and integrity of the application. RDBMS stands for – Relational Database Management System.
Transaction Management can be described using the ACID properties. ACID stands for Atomicity, Consistency, Isolation and Durability.