The code is as follows:
<%
Class.forName("com.mysql.jdbc.Driver");
The String url="JDBC: mysql://localhost: 3306/JDBC";
String userName="root";
String passWord="CDR";
The Connection conn=DriverManager. GetConnection (url, userName, passWord);
String SQL="insert into users (name, password, email, birthday) values (?,?,?,?,? ,? ,? ,?) ";
PreparedStatement preStmt=conn. PrepareStatement (SQL);
PreStmt. SetString (1, "Jim");
PreStmt. SetString (2, "jjja");
PreStmt. SetString (3, "15821452 @qq.com");
PreStmt. SetString (4, "1996-01-12");
Int I=preStmt. ExecuteUpdate ();
If (i> 0 {
Out.println (" successfully adding "+ I +" line ");
}
conn.close();
PreStmt. Close ();
%>
CodePudding user response:
how to still use JSPCodePudding user response:
Should be after you add, to request the database, then use js to add it againCodePudding user response: