First, JDBC
1.JDBC
Java database connection, used in Java programs to implement database operations, JAVA.SQL package provides the execution of SQL statements, access to a variety of database methods, and for a variety of different databases to provide a unified interface and classes of operations.
2. Operation procedure
- Load the JDBC drive and load the JDBC driver into the classpath.
- Load the JDBC driver and register it in DriverManager. General use of reflection mechanism Class.forName (String drivername)
- Establish database connection, get Connection object. Typically implemented through the Drivermanager.getconnection (url,username,passwd) method, where the URL represents a string that connects to the database, Uaername represents the user name of the connection database, and passwd represents the password for the connection database.
- Establishes a statement object or Preparestatement object.
- Executes the SQL statement.
- Accesses the structure set ResultSet object.
- Access resultset, Statement, PreparedStatement, and connection objects down, freeing up the resources that are occupied.
3. Cite an example of accessing MySQL
Ii. methods used by JDBC to process transactions
Java Database Operations