Import jar Package mode
import java.sql.*; public class jdbcdeno1 { public static void main(String[]
args){ // (" link url+/ Database name "," user name "," password "); try(Connection connection= DriverManager.
getConnection("jdbc:mysql://localhost:3306/ooo","root","123456"); Statement
statement=connection.createStatement()) { // implement sql } catch (SQLException
throwables) { throwables.printStackTrace(); } } }
The following operations are directly in // implement sql Copy and paste the following line
increase :
towards teacher Table insert data 15 number , Name is 15, Gender is female .
statement.executeUpdate("insert into teacher value (15,' fifteen ','2')");
Used here “2” It means female because I directly wrote a female report “Data truncated for column ‘sex’ at row 1” My fault .
Insert multiple rows ( Batch processing ):
statement.addBatch("insert into teacher value (15,' fifteen ','2')"); statement.
addBatch("insert into teacher value (16,'16','2')"); statement.addBatch("insert
into teacher value (17,'17','1')"); statement.executeBatch();
Delete :
Put the newly inserted No 15 Row data deletion
statement.executeUpdate("delete from teacher where tid='15'");
repair :
Put the first 14 The name of No. is changed to 14
statement.executeUpdate("update teacher set name='14' where tid='14'");

Technology