Learning Essentials
- Jdbc
- Querying data
- Add data
- modifying data
- Delete data
Definition of JDBC1 JDBC
JDBC is the abbreviation for Java Database Connectivity technology, providing the ability to connect and manipulate a variety of commonly used databases.
2 How JDBC Works
3 JDBC API
JDBC API main functions: Establish a connection with the database, execute SQL statements, and process the results.
- DriverManager: Depending on the database, the JDBC driver is managed
- Connection: Responsible for connecting to the database and serving the task of transmitting data
- Statement: Generated by Connection, responsible for executing SQL statements
- ResultSet: Responsible for saving the results of the query resulting from statement execution
4 JDBC Work templates
Use the statement object to process the SQL statement.
JDBC Query data
Use the PreparedStatement object to process SQL statements (SQL statements are precompiled, more secure).
JDBC Add data
JDBC Modifies data
Using the PreparedStatement object's executeupdate (), returns the number of rows affected, with the work template adding data.
JDBC Deletes data
Using the PreparedStatement object's executeupdate (), returns the number of rows affected, with the work template adding data.
JavaSE-27 JDBC