日期:2014-05-17 浏览次数:20746 次
<body>
<%int id=Integer.parseInt(request.getParameter("newid"));
String Name=request.getParameter("newName");
String Pwd=request.getParameter("newPwd");
String Sex=request.getParameter("newSex");
int age=Integer.parseInt(request.getParameter("newAge"));
Connection conn=null;
try{
String userid=request.getParameter("userid");
String userpassword=request.getParameter("userpassword");
Class.forName("com.mysql.jdbc.Driver").newInstance();
String strConn="jdbc:mysql://localhost:3306/stuinfo";
conn=DriverManager.getConnection(strConn,"root","123");
Statement stat=conn.createStatement();
String sql = "insert into stu values("+id+",'"+Name+"','"+Pwd+"','"+Sex+"',"+age+")";
ResultSet re=stat.executeQuery(sql);
out.println("插入完成");
}
catch(Exception ex){
ex.printStackTrace();
}
conn.close();
%>
</body>