-2

Whenever i create new employee the employee code should be unique. For example, employee code like E00001, E00002, E00003.

  • You can use AUTO_INCREMENT in mysql for your id column, so they will allways be unique and after that, add an E at the beginning – nacho Jan 28 '19 at 09:49

1 Answers1

0

Create a sequence for generate employeeId in MySQL : how ? here the info

//Get the sequence value and assign to local variable I am assuming value is 1 check below code

    String empIdNextSequence = String.valueOf(1);

            if (null != empIdNextSequence && empIdNextSequence.length() < 5)
            {
                int uuidNextSequenceLength = empIdNextSequence.length();
                for (int i = 0; i < 5 - uuidNextSequenceLength; i++)
                {
                    empIdNextSequence = "0".concat(empIdNextSequence);
                }
            }
            System.out.println("E"+empIdNextSequence);

Set empIdNextSequence value to your employeeCode

IMParasharG
  • 1,869
  • 1
  • 15
  • 26