日期:2014-05-17 浏览次数:20695 次
package com.java.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import com.java.dao.IUserDao; import com.jsp_class.com.DataBase; public class UserImpl implements IUserDao{ private DataBase base=new DataBase(); private Connection conn=null; private PreparedStatement ps=null; private ResultSet rs=null; public int userRegister(String uName, String pwd) { int i=0; try{ conn=base.getConn(); System.out.println(conn); String sql="insert into users values(seq_uId.nextval,?,?)"; ps=conn.prepareStatement(sql); ps.setString(1,uName); ps.setString(2,pwd); i=ps.executeUpdate(); base.clearAll(conn,ps,rs); return i; }catch(Exception e){ e.printStackTrace(); } return i; } }
<body> <% String name=request.getParameter("uName"); //获取上一页面用户名 String pwd=request.getParameter("uPwd"); //获取上一页面用户密码 UserImpl userimpl=new UserImpl(); int pick=userimpl.userRegister(name,pwd); if(pick>0){ out.print("注册成功"); }else{ out.print("没有插入成功"); } %> </body>