What is JDBC?
JDBC represents a Java database connection and provides a set of Java APIs for Java to access relational databases. These Java APIs allow Java programs to execute SQL statements and interact with any SQL-compatible database.
JDBC provides a flexible framework for writing a data-independent application that can run on a different platform and interact with a database-relational system without any modification
Advantages and disadvantages of JDBC:
Advantages: Clean and simple SQL processing, good performance and big data, very suitable for small applications, simple grammar, easy to learn
Cons: If used in large projects, complex, become expensive, no encapsulation, difficult to implement the MVC concept, query is the specific database management system
What is ORM?
ORM (Object-relational mapping) is a programming idea, in some ways better than JDBC to optimize some
ORM Benefits:
S.N. Advantage 1 Let the business code access the object, not the database table. 2 Object-oriented logical SQL query details are hidden. 3 JDBC-based "under the hood" 4 eliminates the need to process database implementations. 5 entities that are based on business concepts rather than database structures. 6 transaction management and automatic key generation. 7 rapid development of applications.
The ORM solution consists of the following four entities:
S.N. |
Solve |
1 |
An API to perform basic CRUD operations on the objects of a persisted class. |
2 |
Language or API to specify the referenced class and property query for the class. |
3 |
A configurable device that specifies the mapping metadata. |
4 |
Technology interacts with transactional objects to perform dirty data checks, lazy associative loading, and other optimization functions. |
Some Java ORM frameworks
There are several persistence frameworks and Java ORM scenarios. The persistence Framework is an ORM service that stores and retrieves objects to a relational database.
Hibernate
Hibernate is a lightweight ORM framework that has the advantage of being simple to use, powerful, and well-supported for most databases on the market, and that the lightweight framework does not rely on any container
Hibernate principle: Hibernate acts as a DAO layer and automatically generates corresponding SQL statements based on POJO and entity class mappings
ORM and Hibernate overview