01_JDBC basic concept understanding (including examples)

1. What is JDBC?
Java DataBase Connectivity (Java language connection database)

2. The essence of JDBC
JDBC is a set of interface (interface) developed by Sun Company.
The interface has both callers and implementers.
java.sql.*; (There are many interfaces under this package, and the database connection interface of java is under this package)

Why interface-oriented programming?
Decoupling: reduce the coupling degree of the program and improve the scalability of the program.

Why develop a set of JDBC interfaces? (decoupling)

Because the underlying principles of each database are different.
If it is necessary to connect n kinds of databases of different manufacturers through Java, then it is necessary to write n kinds of Java program codes that meet the requirements of various databases.
Suppose your company is going to do a project, and it turns out that n customers require different databases, then the programmers in the company have to write n kinds of Java programs to connect to these n different databases, which must not be exhausted. . .
Therefore, SUN intends to formulate this set of JDBC interfaces, and then various database vendors respond positively, and use this set of JDBC interfaces produced by SUN to implement it, as shown in the following figure

The picture comes from the video tutorial of JDBC from entry to mastery at station b-JDBC Practical Intensive Lecture
insert image description here

For those who still don’t understand, look at the following

Example: For example, a mobile phone is the database of a manufacturer. Now we need to charge the mobile phone. We are the charger, but the charging port of each mobile phone is different. There are lightning for Apple, type-c for Android and old-fashioned mirco-pro

Suppose your girlfriend goes out to play and asks you to bring him a power bank and cable. My girlfriend’s family is rich and has all kinds of mobile phones. I’m so poor that I don’t know what mobile phone she will bring. In order to be able to fulfill her request, I will I had to bring a schoolbag with all kinds of data cables, and the electricity rushed up, but it was too much energy to do this every time.
But my behavior touched the major mobile phone manufacturers. They thought I was a responsible Good Boy, so they spent a lot of money to customize a universal charger for me. It is branched into the charger interface of each mobile phone. From now on, I no longer need to spend a lot of effort to prepare a large number of data cables. I only need to fulfill the requirements of the power bank and prepare a USB interface that can be plugged in. Charging treasure will do. JDBC is this universal charger. It has developed a unified interface for our programmers, which is equivalent to the USB interface on the other end of the universal charger. The realization of the interface by major manufacturers is the data line port of each branch.

Guess you like

Origin blog.csdn.net/qq_45657848/article/details/127472810