JDBC: (Java data Base Connectivity)Java database connection
The java.sql package provides the JDBC API, which allows you to write program code that accesses the database. Common interfaces and classes include the following:
- DriverManager: Driver Manager, responsible for creating database connections
- Connection: representing the database connection
- Statement: Responsible for executing SQL statements
- PreparedStatement: The ability to execute SQL statements with predefined SQL statements
- ResultSet: Query result set on behalf of SQL query statement
Hibernate (Java Object Persistence Technology):Hibernate is an open-source Object-Relational mapping framework that provides JDBC with a very lightweight object Encapsulation that allows Java programmers to manipulate databases at will using object programming thinking . Hibernate can be applied to any JDBC application, both in Java client applications and in servlet/jsp Web applications, and most revolutionary of all, hibernate can replace CMP in the EE architecture of the EJB application. The task of achieving data persistence.
Hibernate has a total of 6 core interfaces: Session, Sessionfactory, Transaction, Query, criteria, and configuration.
Session Interface: is responsible for executing the persisted object crud operation The task of CRUD is to complete the communication with the database, which contains many common SQL statements. )。 However, it is important to note that the session object is non-thread-safe. At the same time, Hibernate's session differs from the HttpSession in JSP applications. When the term "session" is used, it is actually referring to the session in Hibernate, and later the HttpSession object is called the user session.
< Span style= "Color:rgb (51,51,51)" >sessionfactory interface: responsible for initializing hibernate
Transaction interface: is an optional API that allows you to choose not to use this interface instead of the underlying transaction code written by Hibernate's designers themselves. Transaction interface is an abstract
Query
interface: It allows you to make queries to databases and persistent objects conveniently , and it can be expressed in two ways: the HQL language or the SQL statement of the local database. Queries are often used to bind query parameters, limit the number of query records, and ultimately perform query operations.
Criteria Interface: very similar to the query interface, allowing you to create and execute object-oriented, standardized queries . It is important to note that the query interface is also lightweight and cannot be used outside the session.
Configuration
Interface: The function is to configure Hibernate and start it. During Hibernate startup, an instance of the configuration class first locates the location of the mapped document, reads the configuration, and then creates a Sessionfactory object. Although the configuration interface plays only a small role throughout the Hibernate project, it is the object that you encounter when you start hibernate.
Hibernate Object Persistence Framework