Hibernate from Getting started to mastering (i) Introduction to JDBC

Source: Internet
Author: User
Tags driver manager object model

Before we get to know hibernate, let's review the traditional JDBC access to the database. The focus is on analyzing the flaws in JDBC access, how are these flaws thought and resolved in hibernate?

JDBC Main object

Drivemanager: Represents the driver manager and is responsible for creating a database connection

Connection: On behalf of the database connection

Statement: Responsible for executing SQL statements

Preparestatement: Inheriting statement, responsible for executing SQL statements, with predefined SQL statement functionality

Results: A query result set that represents a SQL query statement

JDBC Access Step

1. Load and register driver JDBC Driver

2. Establish database connection

3, create the statement object, and prepare to execute the SQL statement

4. Execute SQL statement

5, turn off statement and connection objects in turn

JDBC Flaw

1, programmers must understand the Java language, but also understand the SQL language, in order to write database access code

2, the program code embedded a large number of string form point of SQL statements, reducing the independence and readability of program code

3, the program code and relational database structure together, weaken the program code independence and reliability. Example: The database table modifies a field name, and the SQL statements involved in the program code are also modified

4, programmers need to understand, objects and tables, attributes and fields corresponding relationship. So programmers need to be familiar with the object model, and need to understand the relationship database, but also to understand the corresponding relationship between the two, so programmers can not follow the full object-oriented thinking to write program code

Once you understand the drawbacks of JDBC access to the database, we'll do a simple example and analyze the hibernate steps and how to solve the drawbacks of JDBC for this example.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.