String driverName=". Com. Mysql. Cj. JDBC Driver ".
//load the JDBC driver
String dbURL="JDBC: mysql://localhost: 3306/javaweb_02? UseSSL=false& ServerTimezone=UTC ";
//connect to the server and the database
String userName="root";//the default user name
String userPwd="root";//password
The Connection conn=null;
The Statement STMT=null;
Try {
Class.forname (driverName);
System. Out.println (" connect to the database... ");
Conn=DriverManager. GetConnection (dbURL, userName, userPwd);
STMT=conn. CreateStatement ();
String SQL="insert into student_02 (id, user, password) values (123, 'silent', '229324')";
Int n=STMT. ExecuteUpdate (SQL);
System. The out. Println (n);
STMT. Close ();
conn.close();
} the catch (a ClassNotFoundException e) {
e.printStackTrace();
{} the catch (SQLException throwables)
Throwables. PrintStackTrace ();
}