Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. org.datanucleus.exceptions.NucleusUserException
- 2. javax.jdo.JDOUserException
- @Entity
- @PersistenceCapable
- public class User {
- @PrimaryKey
- @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
- public String userName;
- @Persistent
- private String name, password, city, bikeModel, age;
- public User(){
- }
- public User(String name, String uname, String pswd, String age, String city, String bike){
- this.name=name;
- this.userName=uname;
- this.password=pswd;
- this.age=age;
- this.city=city;
- this.bikeModel=bike;
- }
- public String getUserName() {
- return userName;
- }
- //rest of the getters
- }
- //Getting SignUp form values
- String name=req.getParameter("name1");
- String uname=req.getParameter("uname1");
- String pswd=req.getParameter("pswd1");
- String age=req.getParameter("age");
- String city=req.getParameter("city");
- String bike=req.getParameter("bike");
- //PeristenceManager instance
- PersistenceManager pm = PMF.get().getPersistenceManager();
- //Creating instance for persistent entity class
- User newEntry=new User(name,uname,pswd,age,city,bike);
- //Query to match the userName entered in form and that of the dataStore user
- Query q = pm.newQuery(User.class);
- q.setFilter("userName == userNameParam");
- q.declareParameters("String userNameParam");
- try{
- List<User> results = (List<User>) q.execute(uname);
- if (!results.isEmpty()) {
- //if userName is found in DataStore
- resp.sendRedirect("invalidUser.html");
- } else{
- //If userName is not found in dataStore
- pm.makePersistent(newEntry);
- resp.sendRedirect("success.html");
- return;
- }
- }
- finally{
- System.out.println("Finally!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement