String q = SQLFormatter.generateQuery("SELECT * FROM %s WHERE email = '%s'",
Employee.getTableName(), data.email);
ResultSet rs = dbConnector.query(q);
if (rs.next()) {
throw new RegistrationFailedException("This email is already in system!");
}
rs.close();
Employee e = new Employee(this, 0, 0, data);
e.setState(Status.NEW);
dbConnector.execute(e.toSQL(owner));
rs = dbConnector.query("SELECT LAST_INSERT_ID() as id FROM " + Employee.getTableName());
rs.next();
e = new Employee(null, rs.getLong("id"), data);
rs.close();
SDBCPool.getInstance().inform(e);
return e;
} catch (SQLException ex) {
logger.severe(null, ex);
//noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException
throw new RegistrationFailedException("Error while checking logindata!");
}
}