Home > Back-end >  JSP to insert data will be inserted into the mysql database twice, why. Idea2020.2 is the use
JSP to insert data will be inserted into the mysql database twice, why. Idea2020.2 is the use

Time:10-12

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 ();
}
  • Related