Connection con = DatabaseConnector.getConnection();
//Hard coded values. Wouldn't it be better for the form values
// to just match the database?
String username = req.getParameter("ajax_username");
String firstname = req.getParameter("firstname");
String lastname = req.getParameter("lastname");
String email = req.getParameter("email");
String password = req.getParameter("password");
String address = req.getParameter("address");
String city = req.getParameter("city");
String state = req.getParameter("state");
String zipcode = req.getParameter("zipcode");
try {
Statement add = con.createStatement();
String sqlstatement = "INSERT USERS (USERNAME,PASSWORD,FIRST_NAME,LAST_NAME,EMAIL,ADDRESS,CITY,STATE,ZIPCODE) " +
" VALUES('"+username+"','"+password+"','"+firstname+"','"+lastname+"','"+email+"','"+address+"','"+
city+"','"+state+"','"+zipcode+"');";
add.execute(sqlstatement);
} catch (SQLException e) {
// TODO: use log4j or other loggin system instead
System.out.println("exception in adding user '"+username+"','"+password+"','"+firstname+"','"+lastname+"','"+email+"','"+address+"','"+
city+"','"+state+"','"+zipcode+" message"+e.getMessage());
return false;
} finally{
if(con != null)
{
try{
con.close();
}catch(SQLException e){}
}
}
return true;