日期:2014-05-19 浏览次数:20747 次
public int registerUser()throws Exception { int i=0; DBconn db=new DBconn(); Connection con=null; PreparedStatement stmt=null; //User u1=new User(); try { con=db.getConnection(); stmt=con.prepareStatement("insert into userTable(name,password) values(?,?)"); stmt.setString(1,username); stmt.setString(2,password); i=stmt.executeUpdate(); }catch(Exception e) { e.printStackTrace(); } finally { stmt.close(); //con.close(); db.closeConnection(con); } return i; } public String execute()throws Exception { if(registerUser()!=0) { return "success"; } else { return "fail"; } }