Java study notes (seven): JDBC

JDBC introduction

JDBC(Java Database Connected)

four Java database operation form:

1.JDBC-ODBC bridging technology (not used); 2. JDBC direct connection; 3. JDBC network connection; 4. Simulate the communication protocol of the specified database and write the database operation yourself.

Several commonly used databases:

Oracle, MySQL, MongoDB, etc.

Connected to the database


In Java, all classes and interfaces for database operations are Saved in the java.sql package, the core components in this package are as follows:

  • One class: DriverManager class;
  • four interfaces: Connection, Statement, ResultSet, PreparedStatement. The operation flow of all JDBC connection databases is fixed, and the following steps are completed: 1. Load the database driver; 2. Connect to the database (through the DriverManager class, Connection indicates the connection); 3. CRUD (Statement, PreparedStatement, ResultSet) of the data; 4. Close database operations and connections.

Load Driver

  • 驱动器:
  • Oracle Driver Class: oracle.jdbc.driver.OracleDriver
  • Load Class Use: Class.forName("oracle.jdbc.driver.OracleDriver ");