/**
  * @user admin
  * @param CandidateAction object
  * @return true if candidate information added in database else false Generates a unique candidate
  *     id for each candidate and fills the candidate information into the database
  */
 public boolean addCandidate(CandidateAction ca) {
   conn = Connect.createConn();
   try {
     int j = genCandidateid();
     query = "insert into its_candidateinformation_tbl values(?,?,?,?,?,?,?,?,?,?,?, default)";
     pstmt = conn.prepareStatement(query);
     pstmt.setInt(1, j);
     pstmt.setString(2, ca.getFname());
     pstmt.setString(3, ca.getLname());
     pstmt.setString(4, ca.getDegree());
     pstmt.setString(5, ca.getStream());
     pstmt.setString(6, ca.getPskillset());
     pstmt.setString(7, ca.getSskillset());
     pstmt.setInt(8, ca.getExperience());
     pstmt.setString(9, ca.getDesignation());
     pstmt.setString(10, ca.getJoining());
     pstmt.setString(11, ca.getLocation());
     int i = pstmt.executeUpdate();
     if (i == 1) {
       message = "Candidate successfully added. Candidate ID is:" + j;
       return true;
     }
     if (i == 0) {
       message = "Candidate could not be added";
       return false;
     }
   } catch (SQLException e) {
     message = "exception occured ";
     System.out.println("Cannot add data into candidate table " + e);
     return false;
   } finally {
     closeConn();
   }
   return false;
 }
 /**
  * @user admin
  * @param CandidateAction object
  * @return LinkedList of CandidateAction type objects who match the search criteria TODO - provide
  *     search methods for individual queries SQL command like is used to search substrings within
  *     Primary Skillset and Secondary Skillset strings stored in database
  */
 public LinkedList<CandidateAction> searchCandidate(CandidateAction ca) {
   conn = Connect.createConn();
   query1 = "SELECT * FROM its_candidateinformation_tbl WHERE ( ";
   query =
       query1
           + " upper(pskillset) like upper(?) AND upper(sskillset) like upper(?) AND experience=?)";
   System.out.println(query);
   lca = new LinkedList<CandidateAction>();
   try {
     pstmt = conn.prepareStatement(query);
     pstmt.setString(
         1, "%" + ca.getPskillset() + "%"); // used %string% format to search within strings
     pstmt.setString(
         2, "%" + ca.getSskillset() + "%"); // used %string% format to search within strings
     pstmt.setInt(3, ca.getExperience());
     rset = pstmt.executeQuery();
     while (rset.next()) {
       System.out.println("within rset");
       ca1 = new CandidateAction();
       ca1.setCandidateid(rset.getInt(1));
       ca1.setFname(rset.getString(2));
       ca1.setLname(rset.getString(3));
       ca1.setDegree(rset.getString(4));
       ca1.setStream(rset.getString(5));
       ca1.setPskillset(rset.getString(6));
       ca1.setSskillset(rset.getString(7));
       ca1.setExperience(rset.getInt(8));
       ca1.setDesignation(rset.getString(9));
       ca1.setJoining(rset.getString(10).substring(0, 10));
       ca1.setLocation(rset.getString(11));
       System.out.println("rset not null");
       System.out.println(ca1.getCandidateid());
       lca.add(ca1);
     }
     if (lca == null) {
       message = "no records found with given search criteria";
       System.out.println("lca is null");
     } else {
       message = "Candidates with given search criteria are given here";
       System.out.println("lca not null");
     }
     return lca;
   } catch (SQLException e) {
     message = "Exception occured in search candidate";
     System.out.println("Candidate info cannot be fetched " + e);
   } finally {
     closeConn();
   }
   return lca;
 }