In depth analysis of JDBC and driver for database connection in Java

In depth analysis of JDBC and driver for database connection in Java

understand:

When a Java application establishes a connection with the database, it first communicates with the driver provided by the database manufacturer through JDBC (JDBC belongs to the JDK), and then the driver communicates with the database.

Driver provided by database manufacturer:

There are many kinds of databases, such as MySQL and Oracle. Different databases have different drivers. Therefore, before other operations, first download and import the corresponding driver jar package.

Connection test steps: first declare the URL, user name and password of the database used (database)

1. Load driver

2. Use connect to establish a connection with the database

There are two ways to load drivers:

Or:

Output:

Database connection succeeded

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>