Add statement:
Statement ST = conn. createstatement ();
String SQL = "insert into user (....) Values (.....) ";
IntNum = st.exe cuteupdate (SQL );
If(Num> 0 ){
System.Out. Println ("inserted successfully !!! ");
}
Delete statement:
Statement ST = conn. createstatement ();
String SQL = "delete from user where id = 1;
IntNum = st.exe cuteupdate (SQL );
If(Num> 0 ){
System.Out. Println ("deleted successfully !!! ");
}
Modify statement:
Statement ST = conn. createstatement ();
String SQL = "update user set name = ''where name = ''";
IntNum = st.exe cuteupdate (SQL );
If(Num> 0 ){
System.Out. Println ("modification successful !!! ");
}
Query statement:
Statement ST = conn. createstatement ();
String SQL = "select * from user where id = 1;
Resultset rs= St.exe cuteupdate (SQL );
While(Rs. Next ()){
// Call the RS Method Based on the Data Type of the retrieved Column
// Map to a Java object
}
Release resources
After the program is running, database-related resources will not be automatically released. We need to manually release the resultset, statement, and connection
Connection is a very valuable resource. It should be released as soon as possible after use.
To ensure that the Code for releasing resources will be executed, we usually put them in finally