Q:

Get identity of last inserted row in Google Apps Script

Platform: Google Apps Script connecting to SQL Server using JDBC service.
How do I get the identity (id) of an inserted row? (code provided below) I believe the solution is here: https://stackoverflow.com/a/42655/3520117 but I'm struggling to implement that general solution in Google Apps Script using the JDBC service.
Code.gs:
function postNewItem(formObject) {

  var useremail = Session.getActiveUser().getEmail();

  var timeZone = CalendarApp.getDefaultCalendar().getTimeZone();
  var timestamp = Utilities.formatDate(new Date(), timeZone, "yyyyMMdd HH:mm:ss"); // get current date/time

  var conn = Jdbc.getConnection(connParams);
  var stmt = conn.prepareStatement('INSERT INTO tblOne '
      + '(email, timestamp, var1, var2, var3) '
      + 'values (?, ?, ?, ?, ?)');
  stmt.setString(1, useremail);
  stmt.setString(2, timestamp);
  stmt.setString(3, formObject.var1);
  stmt.setString(4, formObject.var2);
  stmt.setString(5, formObject.var3);

  stmt.execute();
  conn.commit();
  conn.close();

  // log event
  logEvent(id, "N/A", "New item added.", useremail);
}

A:

Solved. I'm posting this here to benefit anyone else struggling with this.
Steps:

Add autoGeneratedKeys flag
var stmt = conn.prepareStatement(query, 1);
Get a list of auto generated keys
var results = stmt.getGeneratedKeys();
Get ID:
while (results.next()) {
    var id = results.getInt(1);
}

Full example:
Code.gs:
function postNewItem(formObject) {

  var useremail = Session.getActiveUser().getEmail();

  var timeZone = CalendarApp.getDefaultCalendar().getTimeZone();
  var timestamp = Utilities.formatDate(new Date(), timeZone, "yyyyMMdd HH:mm:ss"); // get current date/time

  var conn = Jdbc.getConnection(connParams);
  var stmt = conn.prepareStatement('INSERT INTO tblOne '
      + '(email, timestamp, var1, var2, var3) '
      + 'values (?, ?, ?, ?, ?)', 1); // added autoGeneratedKeys flag
  stmt.setString(1, useremail);
  stmt.setString(2, timestamp);
  stmt.setString(3, formObject.var1);
  stmt.setString(4, formObject.var2);
  stmt.setString(5, formObject.var3);

  stmt.execute();

  // start of additional code
  var results = stmt.getGeneratedKeys();

  while (results.next()) {
    var id = results.getInt(1);
  }

  Logger.log(id);
  // end of additional code

  conn.commit();
  conn.close();

  // log event
  logEvent(id, "N/A", "New item added.", useremail);

