package com;
public class user {
private int id
private String username;
private String userpassword;
private int status;
public int getid() {
return id;
}
public void setid(int id)
{ this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpassword() {
return userpassword;
}
public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}
public int getstatus() {
return status;
}
public void setstatus(int status)
{ this.status = status;
}
}
<jsp:useBean id="user" class="com.user" scope="request">
</jsp:useBean><jsp:setProperty name="user"property="*"></jsp:setProperty>Class.forName("com.mysql.jdbc.Driver");String url="jdbc:mysql://127.0.0.1:3306/submit?user=root&password=root";Connection connection= DriverManager.getConnection(url);
String sql="insert into user(id,username,userpassword,status) values(15,'兰天','3',1)";
Statement stmt=connection.createStatement();
int
count=stmt.executeUpdate(sql);
if (count==0){
out.print("失败");}else{
out.print("成功");}
<form action="insert.jsp"> 学号: <input type="text" name="id"><br> 姓名:<input type="text" name="username"><br> 密码:<input type="text" name="userpassword"><br> 性别:<input type="radio" value="1" name="usersex">男 <input type="radio" value="2"name="status">女<br> <input type="submit" name="usersex" value="注册"><br> </form>