title: How to auto increment employeeID based on values already entered in database?
body: <p>I have a html page and a servlet which is responsible for adding new employee information to a database. Currently, as you can see, the 4 digit employee ID is entered manually by this admin. Is there any way I can auto-generate this, based on values which are already in the database? E.g. if there is an employee with id 0001, then the 4 digit employee ID will automatically be filled out as 0002 or something along those lines? Thanks</p>
  
  <p>Part of code from NewEmployee.html </p>
  
  <pre><code>&lt;form action ="NewEmployeeAccount" method = "post"&gt; 
  
      &lt;table border ="1"&gt; 
          &lt;tr&gt;
              &lt;td&gt;4 digit Employee ID:&lt;/td&gt;
              &lt;td&gt;&lt;input type = "text" name = "employee_id"  pattern="[0-9]{4}" title="4 digit number: e.g. 1234" maxlength="4" required&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td&gt;First Name&lt;/td&gt;
              &lt;td&gt;&lt;input type = "text" name = "firstName"  required&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td&gt;Last Name&lt;/td&gt;
              &lt;td&gt;&lt;input type = "text" name = "lastName"  required&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;br/&gt;&lt;br/&gt;
      &lt;input type = "submit" value = "Create Employee Account"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Part of code from NewEmployeeAccount.java</p>
  
  <pre><code>try {
  
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/payroll_system", "root", "");
      PreparedStatement ps = con.prepareStatement("INSERT INTO payroll_system.employee_info(employeeID, FirstName, LastName) values(?,?,?)");
      ps.setString(1, employee_id);
      ps.setString(2, firstName);
      ps.setString(3, lastName);
  </code></pre>