Esempio n. 1
0
 public static int insertUser(User user) {
   int count = 0;
   String result = "";
   try {
     // getting database connection to MySQL server
     String query =
         "INSERT INTO ad_467de3d0d776395.USER_DET(USER_NAME,PASSWORD,EMAILID,ROLE,RM_ID,RM_EMAILID) VALUES(?,?,?,?,?,?)";
     // dbCon = DriverManager.getConnection(dbURL, dbusername, dbpassword);
     count =
         jdbcTemplate.update(
             query,
             new Object[] {
               user.getUsername(),
               user.getPassword(),
               user.getEmailid(),
               user.getRole(),
               user.getRm_id(),
               user.getRm_Mgr_email()
             });
     System.out.println("count in dao==>" + count);
     result = "User registered Successfully.....";
     SimpleMail sm = new SimpleMail();
     sm.sendMail(user.getEmailid(), user.getUsername());
   } catch (SQLException ex) {
     ex.printStackTrace();
     // Logger.getLogger(CollectionTest.class.getName()).log(Level.SEVERE, null, ex);
     result = "User registration Failed";
   } catch (Exception ex) {
     ex.printStackTrace();
     result = "User registration Failed";
   }
   return count;
 }
Esempio n. 2
0
  public static String updateuserdet(User user) {
    logger.info("  Welcome updateuserdet ");
    int count = 0;
    String result = "";
    try {
      // getting database connection to MySQL server
      // String query ="INSERT INTO
      // ad_467de3d0d776395.USER_DET(USER_NAME,PASSWORD,EMAILID,ROLE,RM_ID,RM_EMAILID)
      // VALUES(?,?,?,?,?,?)";
      String query =
          "UPDATE ad_467de3d0d776395.USER_DET SET PASSWORD='******',EMAILID='"
              + user.getEmailid()
              + "',ROLE='"
              + user.getRole()
              + "',RM_ID="
              + user.getRm_id()
              + ",RM_EMAILID='"
              + user.getRm_Mgr_email()
              + "' WHERE USER_NAME='"
              + user.getUsername()
              + "'";
      // dbCon = DriverManager.getConnection(dbURL, dbusername, dbpassword);
      count =
          jdbcTemplate.update(
              query); // ,new
                      // Object[]{user.getUsername(),user.getPassword(),user.getEmailid(),user.getRole(),user.getRm_id(),user.getRm_Mgr_email()});
      System.out.println("count in dao==>" + count);
      if (count == 1) result = user.getUsername();

    } catch (DataAccessException ex) {
      ex.printStackTrace();
      // Logger.getLogger(CollectionTest.class.getName()).log(Level.SEVERE, null, ex);
      result = "User updation Failed";
    } catch (Exception ex) {
      ex.printStackTrace();
      result = "User updation Failed";
    }
    return result;
  }