Q1. What Is JDBC? Explain Different Types JDBC Drivers With Suitable Diagram
Q1. What Is JDBC? Explain Different Types JDBC Drivers With Suitable Diagram
Q1. What Is JDBC? Explain Different Types JDBC Drivers With Suitable Diagram
Q1. What is JDBC? Explain different types JDBC Drivers with suitable diagram.
JDBC Driver
JDBC Driver is a software component that enables java application to interact with the database. T
JDBC drivers:
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)
The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC
bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged
because of thin driver.
Advantages:
o easy to use.
o can be easily connected to any database.
Disadvantages:
o Performance degraded because JDBC method call is converted into the ODBC
function calls.
o The ODBC driver needs to be installed on the client machine.
2) Native-API driver
The Native API driver uses the client-side libraries of the database. The driver converts JDBC
method calls into native calls of the database API. It is not written entirely in java.
Advantage:
Disadvantage:
The Network Protocol driver uses middleware (application server) that converts JDBC
calls directly or indirectly into the vendor-specific database protocol. It is fully written
in java.
Advantage:
Disadvantages:
4) Thin driver
The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is
why it is known as thin driver. It is fully written in Java language.
Advantage:
Disadvantage:
publicclassGFG {
con = connection.connectDB();
// Condiion check
while(rs.next()) {
intid = rs.getInt("id");
String name = rs.getString("name");
String email = rs.getString("email");
System.out.println(id + "\t\t"+ name
+ "\t\t"+ email);
}
}
// Catch block to handle exception
catch(SQLException e) {
Q4) Write a program to merge data of Table_1 and Table_2 into Table_1
using JDBC. Both Table_1 and Table_2 contains students details of CSE and
CSIT departments.
// Java Program to Join Contents
importjava.sql.*;
publicclassGFG {
publicstaticvoidmain(String[] args)
// Display message
System.out.println(
try{
// Loading driver
// Jars(relevant) or mysql-connector-java-8.0.22
Class.forName("com.mysql.cj.jdbc.Driver");
// Registering driver
// have java.sql.SQLException
// password is ""
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test?serverTimezone=UTC",
"root", "");
try{
// Join
Statement st = con.createStatement();
// Name,caste,NeetMarks,gender
// studentspersonaldetails columns :
// Name,Address,email
// data from
+ "Tble_1"
+ "Table_2");
System.out.println(" StuName"
+ " Gender"
+ "Neet Marks"
+ " Email");
// required fields
while(res.next()) {
String neetMarks
= res.getString("NeetMarks");
// Beautification of output
System.out.format(
"%10s%10s%10s%10s%20s\n", name,
con.close();
catch(SQLException s) {
// exception occurs
System.out.println(
}
// Catch bloack to handle generic java
// exceptions
catch(Exception e) {
// caught here
e.printStackTrace();
intpasswordConditionViolated = 0;
publicInvalidPasswordException(intconditionViolated)
{
super("Invalid Password: ");
passwordConditionViolated = conditionViolated;
}
publicString printMessage()
{
// Call constructor of parent Exception
// according to the condition violated
switch(passwordConditionViolated) {
return("");
}
}
// Driver Class
publicclassPasswordValidator {
// to check space
if(password.contains(" ")) {
thrownewInvalidPasswordException(2);
}
if(true) {
intcount = 0;
if(password.contains(str1)) {
count = 1;
}
}
if(count == 0) {
thrownewInvalidPasswordException(3);
}
}
if(true) {
intcount = 0;
// type casting
charc = (char)i;
if(true) {
intcount = 0;
// type casting
charc = (char)i;
String str1 = Character.toString(c);
if(password.contains(str1)) {
count = 1;
}
}
if(count == 0) {
thrownewInvalidPasswordException(6);
}
}
// Driver code
publicstaticvoidmain(String[] args)
{
try{
System.out.println("Is Password "
+ password1 + " valid?");
isValid(password1);
System.out.println("Valid Password");
}
catch(InvalidPasswordException e) {
System.out.print(e.getMessage());
System.out.println(e.printMessage());
}
Statement interface is used to execute normal SQL queries. You can’t pass the parameters to
SQL query at run time using this interface. This interface is preferred over other two
interfaces if you are executing a particular SQL query only once. The performance of this
interface is also very less compared to other two interfaces. In most of time, Statement
interface is used for DDL statements like CREATE, ALTER, DROP etc. For example,
2) PreparedStatement
3) CallableStatement
Servlet
Q1. What is Servlet? Explain life cycle of servlet with an example.
The web container maintains the life cycle of a servlet instance. Let's see the life cycle
of the servlet:
As displayed in the above diagram, there are three states of a servlet: new, ready and
end. The servlet is in new state if servlet instance is created. After invoking the init()
method, Servlet comes in the ready state. In the ready state, servlet performs all the
tasks. When the web container invokes the destroy() method, it shifts to the end
state.
The web container creates the instance of a servlet after loading the servlet class. The
servlet instance is created only once in the servlet life cycle.
The web container calls the init method only once after creating the servlet instance.
The init method is used to initialize the servlet. It is the life cycle method of the
javax.servlet.Servlet interface. Syntax of the init method is given below:
1. public void init(ServletConfig config) throws ServletException
The web container calls the service method each time when request for the servlet is
received. If servlet is not initialized, it follows the first three steps as described above
then calls the service method. If servlet is initialized, it calls the service method.
Notice that servlet is initialized only once. The syntax of the service method of the
Servlet interface is given below:
The web container calls the destroy method before removing the servlet instance
from the service. It gives the servlet an opportunity to clean up any resource for
example memory, thread etc. The syntax of the destroy method of the Servlet
interface is given below:
1. Session Tracking
2. Session Tracking Techniques
HTTP is stateless that means each request is considered as the new request. It is
shown in the figure given below:
1. User authorization
2. Hidden fields
3. URL rewriting
4. Cookies
5. Session tracking API
The first four methods are traditionally used for session tracking in all the server-side
technologies. The session tracking API method is provided by the underlying
technology (java servlet or PHP or likewise). Session tracking API is built on top of
the first four methods.
1. User Authorization
Users can be authorized to use the web application in different ways. Basic concept is
that the user will provide username and password to login to the application. Based
on that the user can be identified and the session can be maintained.
2. Hidden Fields
3. URL Rewriting
4. Cookies
Cookies are the mostly used technology for session tracking. Cookie is a key value
pair of information, sent by the server to the browser. This should be saved by the
browser in its space in the client computer. Whenever the browser sends a request to
that server it sends the cookie along with it. Then the server can identify the client
using the cookie.
In java, following is the source code snippet to create a cookie:
Session tracking is easy to implement and maintain using the cookies. Disadvantage
is that, the users can opt to disable cookies using their browser preferences. In such
case, the browser will not save the cookie at client computer and session tracking
fails.
Session tracking API is built on top of the first four methods. This is inorder to help
the developer to minimize the overhead of session tracking. This type of session
tracking is provided by the underlying technology. Lets take the java servlet example.
Then, the servlet container manages the session tracking task and the user need not
do it explicitly using the java servlets. This is the best of all methods, because all the
management and errors related to session tracking will be taken care of by the
container itself.
Q3)Write a program to enter user credentials in a login page and validate the
user in the database. If credential is correct redirect to page to display
welcome message else display suitable error message.
Cookies in Servlet
A cookie is a small piece of information that is persisted between the multiple client
requests.
A cookie has a name, a single value, and optional attributes such as a comment, path
and domain qualifiers, a maximum age, and a version number.
Ans
Difference table between Cookies and Session
Session Cookies
A session stores the variables and their values within a file in a Cookies are stored on the user's computer as a text file.
temporary
The session ends when the user logout from the application or Cookies end on the lifetime set by the user.
It can store an unlimited amount of data. It can store only limited data.
We can store as much data as we want within a session, but The maximum size of the browser's cookies is 4 KB.
there is a maximum memory limit, which a script can use at one time,
We need to call the session_start() function to start the session. We don't need to call a function to start a cookie as it is stored within
In PHP, to set a session data, the $_SESSION global variable is used. In PHP, to get the data from cookies, the $_COOKIE global variable is
used.
In PHP, to destroy or remove the data stored within a session, we We can set an expiration date to delete the cookie's data. It
can use the session_destroy() function, and to unset a specific will automatically delete the data at that specific time. There is no
variable, we can use the unset() function. particular function to remove the data.
Sessions are more secured compared to cookies, as Cookies are not secure, as data is stored in a text file, and if any
they save data in encrypted form. unauthorized user gets access to our system, he can temper the data.
Q5) Give a comparative study on justify which one is better session handling
mechanism between Cookie and HttpSession.
The Session and cookies are used by different websites for storing user's data across different
pages of the site. Both session and cookies are important as they keep track of the information
provided by a visitor for different purposes. The main difference between both of them is that
sessions are saved on the server-side, whereas cookies are saved on the user's browser or
client-side.
HTTP is a stateless protocol; hence it does not store any user information. For this purpose, we
can use Cookies. It allows us to store the information on the user's computer and track the state
of applications.
Taking the request from a browser window and processing that request by using multiple servlets as a
chain is called servlet chaining. In servlet chaining, we perform communication between servlet
programs to process the request given by a client.
All servlet programs that participate in a servlet chaining will use the same request and response
objects because they process the same request that is given by the client.
To perform servlet chaining we need the RequestDispatcher object. RequestDispatcher object means
it is the object of a container supplied java class
implementing javax.servlet.RequestDispatcher interface.
Q7 Write a servlet program to submit course name from a HTML page and
display details of all students enrol in that course in a tabular format.
http://mca.ignougroup.com/2017/08/write-and-run-servlet-code-to-fetch-and.html?m=1
out.println("<table border=\"1\"><tr><th>Item_ID</th><th>Item_name</th><
Cart</th></tr>");
if(rs1.next()){
out.println("<form action=\"ChildServlet\">");
out.println("<tr><td>"+ rs1.getFloat("item_id") + "</td>");
out.println("<td>"+ rs1.getString("item_name") + "</td>");
out.println("<td>"+"<a href ='"+ request.getContextPath() +
"/ItemDetail?id="+rs1.getFloat("item_id")+ "'>"+ rs1.getString("title")+"</a>"+
out.println("<td>"+ rs1.getString("category") + "</td>");
out.println("<td> "+ rs1.getFloat("price") + "</td>");
out.println("<td>");
out.println("<input type=\"hidden\" name=\"item_id\" value='"+
rs1.getFloat("item_id") +"'>");
out.println("<input type=\"hidden\" name=\"name\" value='"+
rs1.getString("item_name") +"'>");
out.println("<input type=\"hidden\" name=\"title\" value='"+
rs1.getString("title") +"'>");
out.println("<input type=\"hidden\" name=\"price\" value='"+
rs1.getFloat("price") +"'>");
}
else
if(!rs1.next()){
out.println("Error");
response.sendRedirect("error.html");
String id = request.getParameter("item_id");
String name = request.getParameter("name");
1
String title = request.getParameter("title");
2
String price = request.getParameter("price");
3
4
5
6
7
8
9 out.println("<table border=\"1\"><tr><th>Item_ID</th><th>Item_name</th><th>
10</th></tr>");
11
12 out.println("<tr><td> "+ id + "</td>");
jsp
Q1 What is the advantage of JSP over servlet? Explain Servlet life cycle with a
suitable example.
Advantages of JSP over Servlets
The web container maintains the life cycle of a servlet instance. Let's see the life cycle
of the servlet:
The classloader is responsible to load the servlet class. The servlet class is loaded
when the first request for the servlet is received by the web container.
The web container creates the instance of a servlet after loading the servlet class. The
servlet instance is created only once in the servlet life cycle.
The web container calls the init method only once after creating the servlet instance. The init
initialize the servlet. It is the life cycle method of the javax.servlet.Servlet interface. Syntax of the
below:
2. public void init(ServletConfig config) throws ServletException
The web container calls the service method each time when request for the servlet is
received. If servlet is not initialized, it follows the first three steps as described above
then calls the service method. If servlet is initialized, it calls the service method.
Notice that servlet is initialized only once. The syntax of the service method of the
Servlet interface is given below:
JSP scripting elements are one of the most vital elements of a JSP code. These <%
%> tags contain JSP scripting elements. These tags are of the utmost importance as,
at the time of translation, the JSP engine will consider anything inside these tags.
Only this code will convert to Java code. Code other than this is plain or HTML text.
The scripting elements thus help to embed java code to the HTML, CSS, JavaScript
code. There are three main subdivisions of scripting elements in JSP.
1. Expression Tags
2. Scriptlet Tags
3. Declaration Tags
They all provide different ways to include java code in a JSP file.
1. Scriptlets in JSP
JSP Scriptlets help in embedding Java in HTML for JSP code. <%___%> tags
contain the Java code and are called as scriptlet tags. Unlike expressions, scriptlets
have a set of statements in Java language. It allows writing java code in it. The Syntax
of Scriptlet tag is as follows:
For Example:
scriptlet.jsp
<html>
<head><title>Scriptlets</title>
</head>
<body>
<h3>--DataFlair--</h3>
int b=4;
int c=5;
out.println("a is: " +a+ "<br>" + "b is:" +b+ "<br>" + "c is:" +c+ "<br>");
%>
</body>
</html>
Explanation
The above code shows the use of a scriptlet tag that embeds the java code in it. The
code inside the scriptlet tag will go _jspService() method and will become pure java
code. The following is the output.
Output:
2. JSP Expressions
JSP Expression tags, as the name suggests, evaluates expressions. They incorporate
arithmetic and logical expressions so that they can be evaluated. They form an easy
means to access the value of a Java variable. The Expressions in JSP can be an access
point for other expressions and merge that value in an HTML file. They can easily
access data stored in applications.
These expressions or statements can be any valid Java statement. This code gets
converted to out.print( ) statement when an auto generated servlet gets formed. Use
of expressions generates scriptless code.
Following are the examples of expressions in JSP.
a. expression.jsp
<html>
<head><title>Expressions</title>
</head>
<body>
<h3>--DataFlair--</h3>
<%=s1.toUpperCase() %>
</body>
</html>
b. expression2.jsp
<html>
<head><title>Expressions2</title>
</head>
<body>
<h3>--DataFlair--</h3>
<%=n1+n2 %>
</body>
</html>
Explanation
1. In this example, we can see the use of expression to get the result of the logical
expression. The result is shown in the output below.
Output:
2. Contrary to the first example, we can see the use of arithmetic in the JSP code. The
output is below.
Output:
3. JSP Declarations
Unlike the other two, this code doesn’t go to _jspService() method. This code rather
goes to the source file that gets generated outside the _jspService method.
<html>
<head><title>Declaration</title>
</head>
<body>
<h3>--DataFlair--</h3>
<% n=num1+num2+1;
</body>
</html>
Explanation:
In this code, we declared num1 and num2. Then we performed calculations on it. It
will thus generate the following output.
Output:
Q3 What are the implicit objects defined in JSP? Briefly explain about them.
https://www.tutorialspoint.com/jsp/jsp_implicit_objects.htm#:~:text=Th
ese%20Objects%20are%20the%20Java,also%20called%20pre%2Ddefined
%20variables.
Q4 Create a registration form in JSP and store the data in a database table. If
successfully registered give a confirmation else print a suitable error
message.
<%-- Set the value of the created bean using form data --%>
<jsp:setPropertyname="snr"property="user"/>
<jsp:setPropertyname="snr"property="pass"/>
Outputs:
login.jsp
Next on clicking ‘SUBMIT’ button following page is generated.
acceptuser.jsp
Q6) Write a program to login to a website and print all students records from
a STUDENT_DETAILS table in tabular format.
Q7) Explain how JSP utilizing rich features of servlet and making it simple.
Mentioned few differences between JSP and Servlet.
JSP
SERVLET
JSP runs slower than servlet as it
Servlets run faster than JSP. takes time to compile the program
and convert into servlets.
It’s easier to code in JSP compared
It is hard to write code in servlet.
to servlets.
In MVC architecture, servlet works as a In MVC architecture, JSP works as a
controller. view for displaying output.
JSP is generally used when there is
It should be use when there is more
no involvement of much data
data processing involved.
processing.
There is no custom tag writing facility You can easily build custom tags
in servlets. that can directly call Java beans.
Servlet is a java code. JSP is a HTML-based code.
It can accept all protocol requests,
It can only accept HTTP requests.
including HTTP.
In JSP, you can’t override the
You can override the service() method.
service() method.
In Servlet, by default, session
In JSP, session management is
management is not enabled, user has
automatically enabled.
to enable it explicitly.
In Servlet, you have to implement both
In JSP, business logic is split from
business logic and presentation logic in
presentation logic using JavaBeans.
the single file.
Modification in Servlet file is a time
JSP modification is fast, as you just
consuming due to reloading,
need to click one refresh button.
recompiling, and restarting the server.
Q8)Explain Session Tracking in JSP. How session object can be used to handle
session in JSP.
Ans- https://www.javawebtutor.com/articles/jsp/jspsession.php
Hibernate:
Q1) What is ORM? Explain the use case for hibernate with a suitable diagram.
Ans- Object-relational mapping (ORM) is a programming technique in which a
metadata descriptor is used to connect object code to a relational database.
Object code is written in object-oriented programming (OOP) languages such as
Java or C#. ORM converts data between type systems that are unable to coexist
within relational databases and OOP languages
https://www.tutorialspoint.com/hibernate/hibernate_quick_guide.htm
Hibernate Configuration File(cfg file) is the file loaded into an hibernate application when
working with hibernate.Hibernate uses this file to establish connection to the database
server.It is an XML file which is used to define below information.Standard name for this file
is hibernate.cfg.xml.
1<hibernate-configuration>
2<session-factory>
3
4
<! -- Related to the connection START -->
5
<propertyname="connection.driver_class">Driver Class Name </property>
6
<propertyname="connection.url">URL </property>
7
<propertyname="connection.user">USER NAME </property>
8
<propertyname="connection.password">PASSWORD</property>
9
<! -- Related to the connection END -->
10
11
<! -- Related to hibernate properties START -->
12
<propertyname="show_sql">true/false</property>
13
<propertyname="format_sql">true/false</property>
14
<propertyname="use_sql_comments">true/false</property>
15
16<propertyname="dialet">Database dialet class</property>
17<propertyname="hbm2ddl.auto">create/create-drop/update/validate</property>
18<! -- Related to hibernate properties END-->
19
20<! -- Related to mapping START-->
21<mappingresource="hbm file 1 name .xml"/ >
22<mappingresource="hbm file 2 name .xml"/ >
23<! -- Related to the mapping END -->
24
25</session-factory>
</hibernate-configuration>
https://docs.oracle.com/cd/E89497_01/html/rpm_80_installation/GUID-
47D444D6-0C07-4B0B-BA28-0882D9B55683.htm
The Java Persistence API (JPA) is a specification of Java. It is used to persist data
between Java object and relational database. JPA acts as a bridge between object-
oriented domain models and relational database systems.
Hibernate Architecture:
Configuration:
• Configuration is a class which is present in org.hibernate.cfg
package. It activates Hibernate framework. It reads both
configuration file and mapping files.
• It activate Hibernate Framework
• Configuration cfg=new Configuration();
• It read both cfg file and mapping files
• cfg.configure();
• It checks whether the config file is syntactically correct or not.
•If the config file is not valid then it will throw an exception. If it is
valid then it creates a meta-data in memory and returns the meta-
data to object to represent the config file.
SessionFactory:
• SessionFactory is an Interface which is present in org.hibernate
package and it is used to create Session Object.
• It is immutable and thread-safe in nature.
• buildSessionFactory() method gathers the meta-data which is
in the cfg Object.
• From cfg object it takes the JDBC information and create a
JDBC Connection.
• SessionFactory factory=cfg.buildSessionFactory();
Session:
• Session is an interface which is present in org.hibernate package.
Session object is created based upon SessionFactory object i.e.
factory.
• It opens the Connection/Session with Database software through
Hibernate Framework.
• It is a light-weight object and it is not thread-safe.
• Session object is used to perform CRUD operations.
• Session session=factory.buildSession();
Transaction:
• Transaction object is used whenever we perform any operation and
based upon that operation there is some change in database.
• Transaction object is used to give the instruction to the database to
make the changes that happen because of operation as a
permanent by using commit() method.
• Transaction tx=session.beginTransaction();
• tx.commit();
Query:
• Query is an interface that present inside org.hibernate package.
• A Query instance is obtained by calling Session.createQuery().
• This interface exposes some extra functionality beyond that
provided by Session.iterate() and Session.find():
1. A particular page of the result set may be selected by
calling setMaxResults(), setFirstResult().
2. Named query parameters may be used.
• Query query=session.createQuery();
Criteria:
• Criteria is a simplified API for retrieving entities by composing
Criterion objects.
• The Session is a factory for Criteria. Criterion instances are usually
obtained via the factory methods on Restrictions.
• Criteria criteria=session.createCriteria();
Flow of working during operation in Hibernate Framework :
Suppose We want to insert an Object to the database. Here Object is nothing
but persistence logic which we write on java program and create an object of
that program. If we want to insert that object in the database or we want to
retrieve the object from the database. Now the question is that how hibernate
save the Object to the database or retrieve the object from the database.
There are several layers through which Hibernate framework go to achieve
the above task. Let us understathe nd the layers/flow of Hibernate framework
during performing operations:
Stage I: In first stage, we will write the persistence logic to perform some
specific operations to the database with the help of Hibernate Configuration
file and Hibernate mapping file. And after that we create an object of the
particular class on which we wrote the persistence logic.
Stage II:In second stage, our class which contains the persistence logic will
interact with the hibernate framework where hibernate framework gives some
abstraction do perform some task. Now here the picture of java class is over.
Now Hibernate is responsible to perform the persistence logic with the help
of layers which is below of Hibernate framework or we can say that the
layers which are the internal implementation of Hibernate.
Stage III:In third stage, our hibernate framework interact which JDBC, JNDI,
JTA etc to go to the database to perform that persistence logic.
Stage IV & V:In fourth & fifth stage, hibernate is interact with Database with
the help of JDBC driver. Now here hibernate perform that persistence logic
which is nothing but CRUD operation. If our persistence logic is to retrieve an
record then in the reverse order it will display on the console of our java
program in terms of Object.
Short Questions
Hibernate:
Q1) List out benefits of using Hibernate Framework?
Hibernate framework is open source under the LGPL license and lightweight.
2) Fast Performance
Hibernate framework provides the facility to create the tables of the database
automatically. So there is no need to create tables in the database manually.
Hibernate supports Query cache and provide statistics about query and database
status.
1. Hibernate code will work well for all databases, for ex: Oracle,MySQL, etc. where as
JDBC is database specific.
3. Query tuning is not required in Hibernate. The query tuning is automatic in hibernate by
using criteria queries, and the result of performance is at its best. Where as in JDBC the
query tuning is to be done by the database authors.
4. With the support of cache of hibernate, the data can be placed in the cache for better
performance. Where as in JDBC the java cache is to be implemented.
o Configuration
o SessionFactory
o Session
o Query
o Criteria
o Transaction
jsp:param sets the parameter value. It is used in forward and include mostly.
Object Type
out JspWriter
request HttpServletRequest
response HttpServletResponse
config ServletConfig
application ServletContext
session HttpSession
pageContext PageContext
page Object
exception Throwable
You first set "errorPage" attribute of PAGE directive to the name of the error page (ie
errorPage="error.jsp")in your jsp page .
Then in the error.jsp page set "isErrorpage=TRUE".
When an error occur in your jsp page, then the control will be automatically forward
to error page.
• Compilation
• Initialization
• Execution
• Cleanup
• The JSP container interprets the standard directives and actions, and
the custom actions referencing tag libraries (they are all part of JSP
page and will be discussed in the later section) used in this JSP
page.
• In the above pictorial description, demo.jsp is translated to
demo_jsp.java in the first step
1. Servlets use println statements for printing an HTML document which is usually very
difficult to use. JSP has no such tedius task to maintain.
2. JSP needs no compilation, CLASSPATH setting and packaging.
3. In a JSP page visual content and logic are seperated, which is not possible in a servlet.
4. There is automatic deployment of a JSP, recompilation is done automatically when
changes are made to JSP pages.
5. Usually with JSP, Java Beans and custom tags web application is simplified.
Servlet:
Q1) Differentiate between GET and POST method?
Q2) Compare web server and application server?
Example :
Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
JDBC:
Q1) What is the difference between execute, executeQuery, executeUpdate?
Q2) What is JDBC ResultSet?
The Java JDBC ResultSet interface represents the result of a database
query. The text about queries shows how the result of a query is returned
as a java.sql.ResultSet. This ResultSet is then iterated to
inspect the result.
Q3) List out different types of JDBC Drivers?
Precompiles and caches the SQL statement for faster execution and to
reuse the same SQL statement in batch.
PreparedStatement provides clear separation between the query code and
the parameter values that improves readability.