Enterprise Application Development Assignment 3 - 102606
Enterprise Application Development Assignment 3 - 102606
JDBC or Java Database Connectivity is a Java API to connect and execute the query with the database. It is
a specification from Sun micro systems that provides a standard abstraction (API or Protocol) for java
applications to communicate with various databases like Oracle, MS Access, Mysql, and SQL server database.
It provides the language with java database connectivity standards.
JDBC (Java Database Connectivity) and ODBC (Open Database Connectivity) are both technologies that
Provide a standardized way for applications to interact with databases. JDBC and ODBC serve the purpose of
connecting applications to databases, they differ in terms of platform support, language specificity, driver
Models, and the ecosystems they are commonly associated with. The choice between them depends on the
specific requirements of the application and the programming languages and platforms being used.
Platform and Language: JDBC is a Java-based API, primarily used for connecting Java applications to
databases. It is platform-independent and specifically designed for Java. ODBC, on the other hand, is a C-based
API that can be used with various programming languages. It is not limited to a single language and can be used
on Windows and some non-Windows platforms.
Driver Model: JDBC drivers are typically written in Java, making them platform-independent. JDBC drivers
can be categorized into four types: Type-1, Type-2, Type-3, and Type-4.ODBC drivers are typically
Written in C and can be platform-specific. ODBC drivers need an ODBC driver manager to work with different
databases.
JDBC drivers are client-side adapters (installed on the client machine, not on the server) that convert requests
from Java programs to a protocol that the DBMS can understand.
There are 4 types of JDBC drivers:
Type-1 driver or JDBC-ODBC bridge driver
Type-2 driver or Native-API driver
Type-3 driver or Network Protocol driver
Type-4 driver or Thin driver
Type 1 driver, a JDBC Bridge is used to access ODBC drivers installed on each client machine. Using
ODBC, requires configuring on your system a Data Source Name (DSN) that represents the target database.
The JDBC type 2 driver, also known as the Native-API driver, is a database driver implementation that
uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of
the database API. For example: Oracle OCI driver is a type 2 driver.
The JDBC Type 3 driver is a network-protocol (all-Java driver). This type of driver translates JDBC calls
into the middleware vend or’s protocol, which is then translated to a DBMS protocol by a middleware
server.
The middleware provides connectivity to many different databases.
The JDBC type 3 driver, also known as the Pure Java driver for data base middleware, Is a data base driver
implementation which makes use of a middle tier between the call in program and the database.
The middle-tier (application server) converts JDBC calls directly or indirectly into a vendor-specific
database protocol.
Type-4 JDBC driver also known as' thin driver' or Direct to Database Pure Java Driver. It is portable, the
fastest among all JDBC drivers and database dependent. The thin driver converts JDBC calls directly in to
the vendor-specific database protocol. It is fully written in Java language.
The JDBC type 4 driver, also known as the Direct to Database Pure Java Driver, is a database driver
implementation that converts JDBC calls directly into a vendor-specific database protocol. Written
completely in Java, type 4 drivers are thus platform independent.
There are 5 steps to connect any java application with the database using JDBC: These steps are as follows:
1. Register the Driver class
2. Create connection
3. Create statement
4. Execute queries
5. Close connection
Java Persistence API: is a collection of classes and methods to persistently store the vast amounts of data into
a database which is provided by the Oracle Corporation. To reduce the bur den of writing codes for relational
object management, a programmer follows the ‘JPA Provider’ framework, which allows easy interaction with
database instance. Here the required framework is taken over by JPA.
7) Explain Java Persistence API architecture in short.
The following image shows the class level architecture of JPA. It shows the core classes and interfaces of JPA.
The following table describes each of the units shown in the previous architecture.
Units Description
Entity Manager Factory This is a factory class of Entity Manager. It creates and
manages multiple Entity Manager instances.
Entity Manager It is an Interface, it manages the persistence operations on
objects. It works like factory for Query instance.
Entities: are nothing but beans or Models. Entities represent persistent data stored in a relational database
automatically using container-managed persistence. They are persistent because their data is stored persistently
in some form of data storage system, such as a database: they do survive a server failure, failover, ora network
failure.
Entity Relationships: Generally the relations are more effective between tables in the database. Here the entity
classes are treated as relational tables (concept of JPA), therefore the relationships between Entity classes are
as follows:
Many To One Relation
The Java Transaction API (JTA) allows applications toper form distributed transactions, that is, transactions
that access and update data on two or more networked computer resources. The JTA specifies standard Java
interfaces between a transaction manager and the parties involved in a distributed transaction system: the
application, the application server, and the resource manager that controls access to the shared resources affected
by the transactions.
10) Différentiâtes between Java Persistence API and Java Transaction API (JTA).
JPA is an object-relational mapping tool that allows mapping between entity objects which are classes
with their corresponding tables and their attributes in the database. Whereas JTA is a tool that allows
you to make multiple transactions in multiple schema.
Database while managing concurrency control. On the other hand, distributed transactions deal with
Transactions that span multiple, geographically distributed databases and require mechanisms for coordinating
and ensuring data consistency across these distributed systems. These are distinct concepts, but in some cases,
distributed transactions can involve concurrent transactions within each of the distributed components.
a) The data in a database can be accessed from anywhere using a mobile database. It provides wireless
database access.
b) The database systems are synchronized using mobile databases and multiple users can access the data
with seamless delivery process.
d) The mobile database can be synchronized with multiple devices such as mobiles, computer devices,
laptops etc.