Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Central India’s Most Trusted Training Institute

What is

JDBC?

JDBC stands for Java Database Connectivity. It is a free open source application programming
interface for Java which enables the application to access the database. It enables the developers
to create queries, update data to the relational database using a Structured Query
Language (SQL).

JDBC Workflow

1. Opens a database connection


2. Sends SQL queries to database using a JDBC driver
3. JDBC driver connects to database
4. Executes the queries to get the result set
5. Sends the data to the application via the driver manager
6. When results are returned, then it processes the data
7. Finally, the connection is closed

403-404, Rafael Tower ,Saket Square, Old Palasiya, Indore


Contact @ - 8319338570 Visit us - www.prestigepoint.in email – hrd@prestigepoint.in
Central India’s Most Trusted Training Institute
Disadvange of JDBC :
1.It can't maintain the database Independent sql statements. i.e In future if there is required to
change the datbase because of maintainance problem then we need to change all sql
statements according to the new database.
JDBC is not easy if it is used in large projects. There is a big programming overhead.
2.We cant move the ResultSet object through the network bcz it is not serialized by default.
3.It is not at all good in the transaction management. Programmer must hardcode the
Transactions and concurrency code in the application.
4.Handling the JDBC connections and properly closing the connection is also a big issue.
Properly closing the connection is must.
4.JDBC is not good for big applications

Why we need to go for Object Relational Mapping(ORM)?


1. while creating JDBC persistence logic, we have to keep the database structure in mind and
according to database structure we have to write JDBC code. After the application is
completed, if the database structure is modified then again we need to make the changes in the
entire application code, when ever the JDBC code is added. It makes burden on a programmer.
2. In real time the data will be in objects and the data will be transferred within the
application, in form of objects.But when storing it in database using JDBC technology, it can
not transfer objects between application and a database, in should be converted to a text and
then the text will be transferred to the database. Here the application code is increased for
converting an object into a text or text into an object . It makes burden on a programmer.
3. JDBC technology uses SQL Opertaions and the SQL based persistence logic is database
dependent.
4. In JDBC technology, we have all checked Exceptions, whenever we add JDBC code in our
application, we need to add try …catch blocks or throws keyword. It makes burden on a
programmer.
5. In JDBC technology some repetive statements are require to perform any operational
database. This repetive statements are called Boiler-Plate code.Because of this a burden on a
programmer will be increased.
6. In JDBC technology, a programmer has to take care about connection management
explicitely. It means the programmers has to handle connection opening and closing properly
with the database. If it is not handled properly then at later time, an application can run out of
connections.

403-404, Rafael Tower ,Saket Square, Old Palasiya, Indore


Contact @ - 8319338570 Visit us - www.prestigepoint.in email – hrd@prestigepoint.in
Central India’s Most Trusted Training Institute
In Order to overcome above drawabacks of JDBC technology , third party vendors
started to providing a special kind of software ORM software or tool.
While using ORM software, it internally uses again JDBC technology for connecting
with database.It means, if ORM softwares,indirectly using JDBC to talk with databases.
The major benefits of ORM softwares including data transfer in objects and the
persistance logic independent of databases.

What is ORM?
ORM is a new kind of persistence Software, which acts like a bridge between Java application
and database and transfers to or form data in the form of objects.
ORM softwares internally uses JDBC, JNDI and JTA(Java transaction API) for
communicating a java application with a database in order to transfer objects between them.
An ORM softwares uses JDBC technology to perform database operations with it.
An ORM softwares uses JNDI when connection pooling technique is applied for obtaing
database connections and JTA is used while managing the database transactions.
Primary fuctionality of all ORM softwares is same i.e. data transfer will be done in form of
objects and the persistance logic is independent of all the databases.

What is Hibernate?

Hibenate is an open source frame work, also called as an ORM tool and it acts as middle layer
between a java application and database and provides persistance and query service in the
form of objects.

Hibernate is a free open source object-relational mapping library for Java which is designed to
map objects to an RDBMS and to implement the object-oriented programming concepts in a
relational database.
Hibernate acts as a abstraction layer on top of JDBC technology.

403-404, Rafael Tower ,Saket Square, Old Palasiya, Indore


Contact @ - 8319338570 Visit us - www.prestigepoint.in email – hrd@prestigepoint.in
Central India’s Most Trusted Training Institute
Advantage :
1. Hibernate has an Exception Translator, which converts checked Exception of JDBC into
unchecked exceptions. So programmer is no need to handle the Exception explicitly.
2. Hibernate has its own query language called Hibernate Query Language (known as HQL).
With this HQL,Hibernate queries becomes database independent.
3. Hibernate has cashing mechanism. It reduces number of round trips between a Java
application and a database, so hibernate increases performance of an application .
4. Hibernate has versioning and Timestamp feature. With this feature, we can come to know
how many times a data is modified and also on what time data is last modified.
5. Hibernate supports Inheritance and polymorphism.
6. With hibernate we can manage data stored across multiple tables by applying relationships
(association).
7. Hibernate is light-weight frame work, because hibernate uses POJO classes for data transfer
between an application and a database.

Hibernate Workflow

1. Unlike JDBC Hibernate connects with the database itself and uses HQL (Hibernate Query
Language) to execute the queries and then it maps the results to the Java objects.
2. The results are mapped to objects based on the properties given in the Hibernate
configuration XML file.

403-404, Rafael Tower ,Saket Square, Old Palasiya, Indore


Contact @ - 8319338570 Visit us - www.prestigepoint.in email – hrd@prestigepoint.in
Central India’s Most Trusted Training Institute
3. The database connection from an application is created using session which also helps in
saving and retrieving the persistent object.
4. Session factory is an interface which helps to create an instance of a session. There must be
only one session factory per database. For example, if you are using MySQL and ORACLE in
your application, one session factory for MySQL and one session factory for ORACLE is
maintained. There will not be more than one session factory per MySQL alone.

403-404, Rafael Tower ,Saket Square, Old Palasiya, Indore


Contact @ - 8319338570 Visit us - www.prestigepoint.in email – hrd@prestigepoint.in

You might also like