Home > front end >  The JSP to connect to the database insert data problems
The JSP to connect to the database insert data problems

Time:09-19

Why would add data to the database into two lines, rather than add a line


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 JSP

CodePudding user response:

Should be after you add, to request the database, then use js to add it again

CodePudding user response:

reference 1st floor XmCui response:
how still use JSP
novice web

CodePudding user response:

refer to the second floor is not single, don't change name response:
should be after you add, to request the database, then use js to add a
no js, I found the reason, because there is something wrong with operation mode

CodePudding user response:

reference 3 floor afternoon boiled water response:
Quote: refer to 1st floor XmCui response:

how still use JSP
novice web
you use PHP? Or in other?
  • Related