Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Enterprise Java SEM V Prof.

Jayashree Chaudhari

 What is an Enterprise Application?


 An enterprise application (EA) is a large software system platform designed to operate in a corporate
environment such as business or government.
 EAs are complex, scalable, component-based, distributed and mission critical.
 EA software consists of a group of programs with shared business applications and organizational modeling
utilities designed for unparalleled functionalities.
 EAs are developed using enterprise architecture.
 EA software is a critical component of any computer-based information system.
 EA software ultimately enhances efficiency and productivity through business level support functionality.

The enterprise software includes many functions and abilities:

 Salespeople can log client information,including personal and product information and client location in the
sales pipeline.
 Customer service representatives can track client issues and communication alongside internal responses
and updates.
 Internal-facing employees can take client specifications to build the product.
 Managers and C-level executives can track client and employee performance.

 Architecture of an Enterprise Application


Q:Explain the Architecture of Java Enterprise Application.Nov-18

 Java EE platform uses a distributed multi-tiered application model for enterprise applications.
 Application logic is divided into components according to function and the application components that make
up a Java EE application are installed on various machines depending on the tier in the multi-tiered Java EE
environment to which the application component belongs.
 In distributed computing ,an application is divided into smaller parts that run simultaneously on different
computers.
 The smaller application parts are called tiers.
 Each tier provides an independent set of services that can be consumed by connecting or client tier.
Enterprise architecture is divided into following tiers:
 Client tier components run on the client machine.
 Web tier components run on the Java EE server.
 Business-tier components run on the Java EE server.
 Enterprise Information system(EIS) tier software runs on the EIS server.
Most application have three distinct layers:
 The presentation layer is responsible for the user interfaces.
 The business layer executes the business rules.In the process it also interacts with the data access layer.
 The data access layer is responsible retrieving and manipulating data stored in EIS.

 Challenges of Enterprise Application Development


Q:What are the Challenges of Enterprise Application Development?APR-19
 Enterprise mobility has become the need of the hour.
 With more people bringing in their own devices to work it is necessary to ensure enterprise
application are developed for people to envision productivity and efficiency sailing through
the whole Enterprise
 Security :This is a major concern among Enterprises that are planning for mobility solutions.
With BYOD (bring your own device) gearing up to gain attention, it is necessary for you to
ensure security within your App solution. You have crucial data stored on your Central
database which can be accessed by employees using their own device. In case their device
crashes or is stolen you will face the repercussions .
 Accessibility: Key decision makers within the organization need data to make informed
decisions. They need to know what is happening and what will affect their decisions which
makes data availability crucial to them.Making the data available and accessible in remote
locations becomes essential at such a time.Accessibility is a major challenge for the
Enterprises so that they can make informed and fast decisions sending and receiving mails
becomes easy with the accessibility features and it is important to offer accessibility with high
levels of security
 Improved operations: are essential if you want to improve the performance of your
enterprise application. With the enterprise mobility solution this is forthcoming challenge.You
need to keep a backup of your data to offer consistent performance across the Enterprise
 Strong Networks :Your enterprise mobility is given the strong hold only when you have a
reliable and robust network backing it.It is important to consider the network solution that
will bind your mobility solution, such that you don’t experience any downtime.
 Shortage of Skills: Finding the right skills that will match your needs is the main challenge for
IT industry. When you are getting ready to offer enterprise mobility solutions ,you need to
have the right skills in your team that will take care of cyber security as well as networking
,which is the backbone for your enterprise.

 What is Java Enterprise Edition (Java EE)? Explain.


What is Java Enterprise Edition (Java EE)? Explain.(Nov-19)
The Java Platform Enterprise Edition(Java EE) is a collection of Java APIs owned by Oracle that
software developers can use to write server-side applications.It was formerly known as Java 2
Platform Enterprise Edition or J2EE.
The J2EE is not a product ,rather it is a specification defining a server side Java framework
.Vendors are responsible for using this J2EE spec in order to make compliant J2EE servers.
This allows IT developers to write their Java Business Logic using the J2EE APIs.They do not
have worry about implementing the surrounding framework.
It combines a number of technologies in one architecture with comprehensive Application
Programming Model and Compatibility Test Suite for building enterprise class server side
application.
Java EE applications are hosted on application servers such as IBM’s WebSphere,Oracle’s
Glassfish or Red Hat’s WildFly server,all of which run either in the cloud or within a corporate
data center.While Java EE apps are hosted on the server side ,examples of Java EE clients
include an internet of things(IoT) device,smartphone,RESTful web service ,standard web-
based applications,websocket or even microservices running in a Docker container.
JAVA EE provides collection of:
 Standardized components that facilitates the crafting of commercial applications.
 Standard interfaces that define how the various application modules interconnect.
 Standard services that define how the different software modules communicate.

 Java EE Technologies
1.Web Application Technologies
1.1 Java Servlet API
 The Java Servlet API lets you define HTTP specific classes.
 A servlet class extends the capabilities of servers that host applications that are accessed by way of a
request response programming model.
 Although servlets can respond to any type of request, they are commonly used to extend the applications
hosted by web servers.
 Servlet can accept the input from an online form and print it back to the screen in an HTML page and
format or you might use a different servlet to write the data to a file or database instead.
 A servlet runs on the server side.

1.2 Java Server Pages Technology

 Java Server Pages(JSP) technology provides simplified ,fast way to create dynamic web content.
 JSP technology enables rapid development of web based applications that are server and platform
independent.
 JSP page a text based document that contains two types of text:
Static data, which can be expressed in any text based format such as HTML, Wireless Markup Language
(WML) or XML.
JSP technology elements, which determine how the page constructs dynamic content.

1.3 Java Server Pages Standard Tag Library

 The Java Server Pages Standard Tag Library (JSTL) encapsulates core functionality common to many JSP
technology based applications.
 Instead of mixing tags from numerous vendors in your applications, you employ a single standard set of
tags.
 This standardization allows you to deploy your applications on any JSP container that supports JSTL and
makes it more likely that the implementation of the tags is optimized.
 JSTL has iterator and conditional tags for handling flow control ,tags for manipulating XML document,
internationalization tags,tags for accessing databases using SQL and tags for commonly used functions
1.4Java Server Faces Technology

 Java Server Faces technology is a UI framework for building web applications.


 The main components of Java Server Faces technology involve a GUI component framework, a flexible
model for rendering components in various markup languages and technologies and a
standardRenderKit for generating HTML markup
 This functionality is available through standard Java APIs and XML based configuration files.

1.5 Facelets

 In Java Server Faces(JSF) Facelets is the default view declaration language(VDL) instead of Java Server
Pages(JSP) with Facelets,you don’t need to configure a view handler Facelets is based on
compositions.A composition defines a JSF UI Components structure in a Facelets page.

2 Enterprise Application Technologies

2.1 Enterprise Java Beans (EJB)

 Enterprise JavaBeans (EJB) technology is the server-side component architecture for Java Platform,
Enterprise Edition (Java EE),EJB technology enables rapid and simplified development of distributed,
transactional ,secure and portable applications based on Java technology.

2.2 Java Message Service(API)

 Messaging is a method of communication between software components or applications.


 A messaging system is a peer to per facility.
 In other words, a messaging client can send messages to and receive messages from any other client.
 Each client connects to a messaging agent that provides facilities for creating, sending, receiving, and
reading messages.
 By combining Java technology with enterprise messaging ,the Java Message Service (JMS) API provides a
powerful tool for solving enterprise computing problems.

2.3Java Persistence API

 The Java Persistence API is Java technology standards –based solution for persistence.
 Persistence uses an object –relational mapping approach to bridge the gap between an object oriented
model and relational database.
 Java technology persistence consists of three areas:
The Java persistence API
The query language
Object relational mapping metadata

2.4 Java Mail API

 Web applications can use the JavaMail API to send email notifications.
 The API has two parts:an application level interface that the application components use to send email and
a service provider interface.
 Service providers implement particular email protocols ,such as SMTP .Several service providers are
included with the JavaMail API package,and others are available separately.
 The Java EE platform includes the JavaMail extension with a service provider that allows application
components to send email.

2.5 Java Transaction API (JTA)

 Java Transaction API(JTA) specifies Java interface between a transaction manager and the parties involved in
a distributed transaction system: the resource manager ,the application server, and the transactional
applications.

2.6 J2EE Connector Architecture


 The J2EE Connector architecture provides a Java technology solution to the problem of connectivity between
the many application servers and today’s enterprise information system (EIS).

 Java EE Container
Q:Classify the EE containers.Explain Nov-18
List and explain Java Container types.Apr-19
The server and containers are as follows:
 Java EE server: The runtime portion of a Java EE product. A Java EE server provides EJB and web
containers.
 EJB container: Manages the execution of enterprise beans for Java EE applications. Enterprise beans
and their container run on the Java EE server.
 Web container: Manages the execution of web pages, servlets, and some EJB components for Java
EE applications. Web components and their container run on the Java EE server.
 Application client container: Manages the execution of application client components. Application
clients and their container run on the client.
 Applet container: Manages the execution of applets. Consists of a web browser and a Java Plug-in
running on the client together.

 Types of System Architecture


 Single tier architecture

One tier architecture has all the layers such as Presentation, Business, Data Access layers
in a single software package.
Applications which handles all the three tiers such as MP3 player, MS Office are come
under one tier application.
The data is stored in the local system or a shared drive.
Advantages:
1. Easy to implement and optimize performance.
2. Do not have compatibility or Context switching issues.
3. The cost of deployment is less.
E.g. Development and management cost.
Disadvantages:
1.Do not support remote/distributed access for data resources.
2.Monolithic manner of the code causes higher maintenance.

 Two-Tier Architecture

The Two-tier architecture is divided into two parts:

1. Client Application (Client Tier)


2. Database (Data Tier)

 Client system handles both Presentation and Application layers and Server system
handles Database layer.
 It is also known as client server application.
 The communication takes place between the Client and the Server.
 Client system sends the request to the Server system and the Server system processes
the request and sends back the data to the Client System
Advantages
1.Easy to implement and modification is bit easy.
2.Communication is faster.
Disadvantages
1.In two tier architecture application performance will be degrade upon increasing the
users.
2.Cost-ineffective.
 Three-Tier Architecture

The Three-tier architecture is divided into three parts:

1. Presentation layer (Client Tier)


2. Application layer (Business Tier)
3. Database layer (Data Tier)

Client system handles Presentation layer, Application server handles Application layer
and Server system handles Database layer.
1. Client layer: Represents Web browser, a Java or other application.Applet,WAP phone etc.
The client tier makes requests to the Web server who will be serving the request by either
returning static content if it is present in the web server or forwards the request to either
Servlet or JSP in the application server for either static or dynamic content.
2. Business layer: This layer provides the business services. This tier contains the business
Logic and business data. All the business logic like validation of data calculations, data
Insertion etc.
3. Data layer: This layer is the external resource such as a database,ERP system, Mainframe
System etc. responsible for storing the data. This tier is known as Data Tier.
Advantages:
1. High performance, lightweight persistent objects and better re-usability.
2. Scalability: Each tier can scale horizontally.
3. Performance: Because the presentation tier can cache requests, network utilization is
Minimized and the load is reduced on the Application and Data tiers.
4. Improved Security: Client is not direct access to database.
5.Improve Data Integrity.
6.Forced separation of user interface logic and business logic.

 The Need For Dynamic Content:


 In the earlier days,web pages were static i.e a user requests a resource [such as a web
page,an image,a video and so on] and the server returns it.
 However,with the growth of commercial activities on the Web and the rapid spread and
adoption of the World Wide Web as a network without geographical
boundaries,companies wanted to deliver dynamic content to their customer such as:
 Displaying bank account details
 Performing bank transactions
 Booking Tickets
 Weather reports
 News headlines

 Common Gateway Interface(CGI)


 What are the alternatives to CGI?Explain in detail. Apr-19
Before Servlets, CGI(Common Gateway Interface) programming was used to create web
applications. Here's how a CGI program works :

 User clicks a link that has URL to a dynamic page instead of a static page.
 The URL decides which CGI program to execute.
 Web Servers run the CGI program in seperate OS shell. The shell includes OS enviroment and
the process to execute code of the CGI program.
 The CGI response is sent back to the Web Server, which wraps the response in an HTTP
response and send it back to the web browser.

Drawbacks of CGI programs

 High resposne time because CGI programs execute in their own OS shell.
 CGI is not scalable.
 CGI programs are not always secure or object-oriented.
 It is Platform dependent.
 If the number of clients increases, it takes more time for sending the response.

Because of these disadvantages, developers started looking for better CGI solutions. And then Sun
Microsystems developed Servlet as a solution over traditional CGI technology.

 What is a web application?

A web application is an application accessible from the web. A web application is composed
of web components like Servlet, JSP, Filter, etc. and other elements such as HTML, CSS, and
JavaScript.

The web components typically execute in Web Server and respond to the HTTP request.

 Servlet

 Servlet technology is used to create a web application (resides at server side and
generates a dynamic web page).
 Servlet technology is robust and scalable because of java language.
 There are many interfaces and classes in the Servlet API such as Servlet, GenericServlet,
HttpServlet, ServletRequest, ServletResponse, etc.

 What is a Servlet?
o Servlet is a technology which is used to create a web application.
o Servlet is an API that provides many interfaces and classes including documentation.
o Servlet is an interface that must be implemented for creating any Servlet.
o Servlet is a class that extends the capabilities of the servers and responds to the incoming
requests. It can respond to any requests.
o Servlet is a web component that is deployed on the server to create a dynamic web page.

 Servlet Advantages
 Performance is significantly better.
 Servlets executes within the address space of a web server.It is not create a separate
process to handle each client request.
 Servlets are platform independent because they are written in Java.
 Java security manager on the server enforces set of restrictions to protect the
resources on a server machine.so servlets are trusted.
 The full functionality of Java class libraries is available to servlet. It can communicate
with applet, database or other software via the sockets and RMI mechanisms that you
have seen already.

 Write a short note on javax.servlet package


 Servlet API The javax.servlet and javax.servlet.http packages represent interfaces and
classes for servlet api.
 The javax.servlet package contains many interfaces and classes that are used by the
servlet or web container.
 These are not specific to any protocol.
 The javax.servlet.http package contains interfaces and classes that are responsible for
http requests only.
 Let's see what are the interfaces of javax.servlet package.
Interfaces in javax.servlet package
There are many interfaces in javax.servlet package.
They are as follows:
1. Servlet 2. ServletConfig 3. ServletRequest 4. ServletContext 5. ServletResponse 6.
SingleThreadModel 7. RequestDispatcher 8. Filter
Classes in javax.servlet package
There are many classes in javax.servlet package. They are as follows:
1.GenericServlet 2. ServletContextEvent
3.ServletInputStream 4.ServletRequestAttributeEvent
5.ServletOutputStream 6.ServletContextAttributeEvent
7.ServletRequestWrapper 8.ServletException
9.ServletResponseWrapper UnavailableException
10.ServletRequestEvent

Interfaces in javax.servlet.http package There are many interfaces in javax.servlet.http


package. They are as follows:
1.HttpServletRequest 2.HttpSessionAttributeListener
3.HttpServletResponse 4.HttpSessionBindingListener
5.HttpSession 6.HttpSessionActivationListener
7.HttpSessionListner

Classes in javax.servlet.http package There are many classes in javax.servlet.http


package. They are as follows:
1. HttpServlet 4. HttpServletResponseWrapper
2. Cookie 5. HttpSessionEvent
3. HttpServletRequestWrapper 6. HttpSessionBindingEvent
 Explain the life cycle of Servlet Nov-19
 Write a short note on Servlet Life Cycle
Each servlet has the same life cycle.
 A server loads and initializes the servlet[init() method]
 The servlet handles zero or more client requests[service() method]
 The servlet removes the servlet(some servers do this step only when they shut down)
[destroy() method]
Step 1:A user enters a URL to a browser. The browser generates an HTTP request for this
URL and this request is sent to the appropriate server.
Step 2: The HTTP request is received by the web server. The server maps this request to a
particular servlet. This servlet is dynamically retrieved and loaded into the server.
Step 3: The server invokes the init() method of the servlet. This method is invoked only
when the servlet id first loaded into the memory. We can pass initialization parameters to
the servlet.
Step 4: The server invokes the service () method of the servlet. This method is called to
process the request HTTP request. The servlet can read data that has been provided in the
HTTP request. The service method can also create a HTTP response for the client.
Step 5: The server calls the destroy () method when a servlet has to be unloaded from the
server memory. Once this method is called,the servlet will give up all file handles that were
allotted it.
Q Explain the types of Servlet
Methods Description
getAttribute() Returns the value of the named server attribute as an Object.
JDBC
 JDBC Architecture
Q:Explain the architecture of JDBC.Nov-18
JDBC Architecture

 The JDBC API supports both two-tier and three-tier processing models for database access but
in general, JDBC Architecture consists of two layers −
• JDBC API: This provides the application-to-JDBC Manager connection.
• JDBC Driver API: This supports the JDBC Manager-to-Driver Connection.
 The JDBC API uses a driver manager and database-specific drivers to provide transparent
connectivity to heterogeneous databases.
 The JDBC driver manager ensures that the correct driver is used to access each data source.
 The driver manager is capable of supporting multiple concurrent drivers connected to multiple
heterogeneous databases.
Following is the architectural diagram, which shows the location of the driver manager with respect
to the JDBC drivers and the Java application –

 TYPES OF DRIVER
 List and explain 4 types of JDBC driver Nov-19
 TYPE 1 DRIVER-JDBC-ODBC BRIDGE

 This driver converts JDBC method calls into ODBC function calls.
 This driver is platform dependent as it makes use of ODBC which depends on native libraries
of the underlying OS also use of thise driver leads to other installation dependencies.
 for example odbc must be installed on the computer having the driver and the database must
support an ODBC driver

Advantages:
• It is very easy to use.
• Almost any database is supported.
Limitations:
• Performance will not be efficient.
• ODBC driver needs to be installed.
• Type 1 drivers are not portable.

 TYPE 2-Native API driver


 Jdbc API calls are converted into C/ C + + API call which are unique to the database.
 These drivers are provided by the database vendors and used in the same manner
jdbc-odbc bridge .
 The vendor specific driver must be installed on each client machine. If we change the
database we have to change the native API as it is specific to database but you may
realize increasing speed with type 2 driver because it ODBC overhead

Advantages
• Faster than Type 1 Driver
Limitations
• Client side Library is not available for all
databases.
• Vendor Client Library needs to be installed.
• It is a Platform dependent.
• Not Thread safe.


 TYPE 3 –NETWORK PROTOCOL DRIVER(MIDDLEWARE DRIVER)
 Type 3 driver also known as pure Java driver for database middleware, is a database driver
implementation which makes use of middle tier between the calling program and the
database .The middle tier converts JDBC calls directly or indirectly into the vendor-specific
database protocol.
 The same driver can be used for multiple databases. The type 3 driver is platform
independent as platform related differences are taken care of by the middleware. Allso
making use of middleware provides additional advantages of security and Firewall access

Advantages:
• No additional library installation is required on
client system.
• No changes are required at client for any DB.
• Supports caching of connection ,Query
results,Load Balancing ,Logging and Auditing etc.
• A Single Driver can handle any database provided
the middleware supports it.
Limitations
• Performance will be slow.
• Requires Database –specific coding
• Maintenance of Network Protocol Driver becomes
costly.

 TYPE 4 DATABASE PROTOCOL DRIVER


 Type 4 driver also known as Direct to Database pure Java driver that converts JDBC calls
directly into vendor specific database protocol.
 This provides better performance than type 1 and type 2 drivers as it does not have
the overhead of conversion of calls into ODBC or database API calls.
 Unlike the type 3 driver it does not need associated software to work.
 As the database protocol is vendor-specific the JDBC client requires separate a driver's
usually vendor supplied to connect to different types of database
Advantages:
• Platform Independent
• No intermediate format is required.
• Application connects directly to the database server
• Performance will be very fast.
• JVM manage all aspects.
Limitations:
• Drivers are database dependent.

 STEPS TO JDBC CONNECTIVITY


1. Import JDBC Packages
Import java.io.*;

2.Load and Register the JDBC Driver


Class.forName(" com.mysql.jdbc.Driver ");

3.Open a connection to the database


 This is done by using the getConnection() method of the DriverManager class.
A call to this method creates an object instance of
the java.sql.Connection class. The getConnection() requires three input
parameters, namely, a connect string, a username, and a password. The
connect string should specify the JDBC driver to be yes and the database
instance to connect to.
 The getConnection() method is an overloaded method that takes
 Three parameters, one each for the URL, username, and password.
Connection conn = DriverManager.getConnection(URL, username, passwd);

4.Create a statement object to perform a query.


This is to instantiate objects that run the query against the database
connected to. This is done by the createStatement() method of the conn
Connection object created above. A call to this method creates an object
instance of the Statement class.
Statement sql_stmt = conn.createStatement();

5. Execute the statement object and return a query resultset.


 This is done by using the executeQuery() method of the Statement object.
ResultSet rset = sql_stmt.executeQuery ("SELECT * FROM STUDENT");
6. Process the resultset
 Once the query has been executed, there are two steps to be carried out:
i)Processing the output resultset to fetch the rows
ii)Retrieving the column values of the current row
 The first step is done using the next() method of the ResultSet object. A call
to next() is executed in a loop to fetch the rows one row at a time, with each
call to next() advancing the control to the next available row.
The next() method returns the Boolean value true while rows are still available
for fetching and returns false when all the rows have been fetched.
 The second step is done by using the getXXX() methods of the JDBC rset
object. Here getXXX() corresponds to the getInt(), getString() etc with XXX
being replaced by a Java datatype.
while(rs.next())
{
out.println(rs.getInt(1) +” “ +rs.getString(2) +” “+rs.getString(3));
}
7.Close the Connection
sql_stmt.close();
rset.close();
conn.close()

 Scrollable Resultset in JDBC


1)Non-Scrollable ResultSet
2)Scrollable ResultSet
 By default a ResultSet Interface is Non-Scrollable.
 In non-scrollable ResultSet we can move only in forward direction (that means from
first record to last record), but not in Backward Direction, If you want to move in
backward direction use Scrollable Interface.

Non-Scrollable ResultSet Scrollable ResultSet

Cursor move only in forward Cursor can move both forward and
direction backward direction

Slow performance, If we want to Fast performance, directly move on


move nth record then we need to any record.
n+1 iteration
Non-Scrollable ResultSet cursor can Scrollable ResultSet cursor can move
not move randomly randomly

Create Scrollable ResultSet


To create a Scrollable ResultSet, create Statement object with two parameters
Statement stmt=con.CreateStatement(param1,param2);
//param1 type and param2 mode
Type:
public static final int TYPE_FORWARD_ONLY=1003
public static final int TYPE_SCROLL_INSENSITIVE=1004
public static final int TYPE_SCROLL_SENSITIVE=1005
Mode:
public static final int CONCUR_READ_ONLY=1007
public static final int CONCUR_UPDATABLE=1008
Example:-
Statement stmt=con.CreateStatement(1004,1007) //OR//
Statement stmt=con.CreateStatement(ResutlSet.TYPE_SCROLL_INSENSITIVE ,
ResultSet.CONCUR_READ_ONLY)
Methods of Scrollable ResultSet:
i)afterLast Used to move the cursor after last row.
ii)BeforeFirst: Used to move the cursor before first row.
iii)previous: Used to move the cursor backward.
iv)first: Used to move the cursor first at row.
v)last: Used to move the cursor at last row.
//The following program demonstrates the scrollable resultset
import java.sql.*;
class ScrollableTest
{
public static void main(String[] args) throws Exception
{
Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@John-
pc:1521:xe","system","system");
Statement
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery("select * from student");

//reading from button to top


rs.afterLast();
while(rs.previous())
{
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
}
//move the cursor to 3rd record
rs.absolute(3);
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));

//move the cursor to 2nd record using relative()


rs.relative(-1);
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
int i=rs.getRow(); // get cursor position
System.out.println("cursor position="+i);

//cleanup
rs.close();
stmt.close();
con.close();
}
}
 Transcation Management in JDBC
 A transaction is a group of operation is used to performed one task if all operations in the
group are success then the task is finished and transaction successfully completed.
 If any one operation in the group is failed then the task is failed and transaction is failed.
 Suppose a movie ticket booking at online is a transaction. This task contains four operation.
a.Verify the seats
b.Reserve the seats
c.Payment
d.Issue tickets
 If all the above four operations are done successfully then a transaction is finished
successfully. In the middle, if any one operation is failed then all operation are canceled and
finally a transaction is failed.
 Properties of Transaction managements
 Every transaction follows some transaction properties these are called ACID properties.

Advantage of Transaction Management


fast performance- It makes the performance fast because database is hit at the time of
commit
Types of Transaction
i)Local Transaction
ii)Distributed or global transaction
Local Transaction
A local transaction means, all operation in a transaction are executed against one database.
For example; If transfer money from first account to second account belongs to same bank then
transaction is local transaction.
Global Transaction
A global transaction means, all operations in a transaction are executed against multiple
database.
For Example; If transfer money from first account to second account belongs to different banks then
the transaction is a global transaction
Things required for transaction in Jdbc
Step 1: Disable auto commit mode of Jdbc
Step 2: Put all operation of a transaction in try block.
Step 3: If all operation are done successfully then commit in try block, otherwise rollback in
catch block
By default in Jdbc autocommit mode is enabled but we need to disable it. To disable call
setAutoCommit() method of connection Interface.
con.setAutoCommit(false);
To commit a transaction, call commit() and to rollback a transaction, call rollback() method of
connection Interface respectively
con.commit();
con.rollback();

 ROWSET
 Explain ROWSET and its types in JDBC.APR-19
Why need RowSet?
Database Management Systems or the drivers providedby some database vendors do not support
result setsthat are scrollable and/or updatable.
Benefits of RowSet
provides scrollability and updatability for any kind of DBMS or driver.
A RowSet object, being a JavaBeans component can be used to notify other registered GUI
components of a change.
Types of RowSets
RowSets are classified depending on the duration of their connection to the database
=> Connected or Disconnected
A connected Rowset obj uses a JDBC driver to establish a connection that maintained throughout the
lifespan of the RowSet obj.
A disconnected RowSet obj connect to read or write. After completion, it disconnects from the data
source.
Implementation of “RowSet”
CachedRowSet . disconnected rowset that caches its data in memory . Ideal way to provide thin Java
clients (PDA …)
JdbcRowSet . connected rowset that serves mainly as a think wrapper around ResultSet object
WebRowSet . connected rowset that uses the HTTP protocol internally to talk to a Java servlet that
provides data access
CachedRowSet stores or caches its data in memory so that it can operate on its on data rather than
depending on the data stored in a db. http://pastebin.com/6haZewcS
JdbcRowSet A JdbcRowSet obj is an enhanced and extended ResultSet obj which has certain
properties and a listener mechanism that make it a JavaBeans components

You might also like