我正在尝试创建一个注册页面,我没有收到任何错误,但是当我提交结果时。我的数据库没有显示新用户。我认为 executeUpdate 有问题
<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<%
String username=request.getParameter("username");
session.putValue("username",username);
String password=request.getParameter("password");
session.putValue("username",username);
try{
int sqlport = 3306;
String url = "jdbc:mysql://localhost:3306/";
String user = "admin";
String pswd = "admin";
Connection con = DriverManager.getConnection(url, user, pswd);
Statement stmt = con.createStatement();
ResultSet results;
int i=stmt.executeUpdate("insert into users values ('"+username+"','"+password+"')");
}
catch(Exception e){
System.out.print(e);
e.printStackTrace();
}
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./css/styles.css" />
<body>
<form action="register.jsp" method="POST">
<br>Email :<input type="text" name="email" /></br>
<br>First name :<input type="text" name="fname" /><br>
<br>Last name :<input type="text" name="lname" /><br>
<br>User name :<input type="text" name="username" /><br>
<br>password :<input type="password" name="password" /></br>
<input type="submit" value="continue">
</form>
</body>
</html>