JDBC Connection Operation database process :
1. Place the database-driven jar package under the Lib folder.
2. Define driver name (driver), database Url,username,password string constant
3. Register database driver Class.forName ()
4. The Driver management Class (DriverManager) implements the connection interface.
5. Get resultset results by executing SQL statements from the statement class
6. Treatment of the results
java.sql class
Connection:a session with a specific database;
Common methods: Statement createstatement ()
Statement:the object used for executing a static SQL Statement and returning the results it produces.
Common methods: ResultSet executeQuery (String sql)
This method is used to execute SQL query statements such as SELECT, returning a ResultSet object
int executeupdate (String sql)
This method can execute SQL query statements such as update DELETE INSERT, return an integer type, represent the number of rows changed, and return 0 for table changes;
RESULTSET:A table of data representing a database result set
Common methods: Boolean next ()
The resultset contains a pointer that initially points to the first row of the query result, and moves downward through the next () function until the result is null to return False
int getInt (String str)
Gets the integer number of the field STR, similar to the function string getString (String str)
JDBC and java.sql