What is JDBC ?
- JDBC(Java Database Connectivity) is an API which is used to access database in a java program.
- It is a tool for java-database connection.
- There are various methods and queries provided by JDBC for accessing database. For making connections drivers are provided by JDBC.
![What is JDBC](https://cdn.wikitechy.com/interview-questions/java/what-is-jdbc.png)
What is Hibernate ?
- Hibernate is an ORM tool which is used to map database tables to java classes.
- It is easy to implement and using OOP concept of java to database tables.
- Hibernate makes the connection itself and in hibernate to operate over the tables we use hibernate’s query language.
- So in JDBC we were using SQl(structured query language) but here it itself provides the language which is popularly known as Hql.
![What is Hibernate](https://cdn.wikitechy.com/interview-questions/java/what-is-hibernate.png)
Difference between JDBC and Hibernate ?
- Hibernate is ORM wich maps POJO using xml file to access and create data form hatro database. but in jdbc developers has to write code to map object model data to RDBMS and it access.
- JDBC using SQL to access database developer has to effective way to access the database. but hibernate provides HQL which powerful and includes all feature of SQL and supports ploymorphic query.
- Hibernate data transaction is fast due to work is perform due container mean its xml file mostly but JDBC has slow transaction.
JDBC | Hibernate |
---|---|
JDBC does not support lazy loading | Hibernate does support lazy loading which offers better performance |
In JDBC user is responsible for creating and closing the connections |
But in case of hibernate Run time system takes care of creating and closing the connections |
JDBC is a technology | Hibernate is a orm framework |
Does not support associations | support associations. |