Skip to content
Snippets Groups Projects
Commit e1759d2b authored by Rafi Zereselasie (raz070)'s avatar Rafi Zereselasie (raz070)
Browse files

After a change in the database that made email addresses unique, caused a bug...

After a change in the database that made email addresses unique, caused a bug where new employees on the app to not be added after the first one.
parent e29bee84
No related branches found
No related tags found
No related merge requests found
...@@ -42,9 +42,15 @@ public class Staff { ...@@ -42,9 +42,15 @@ public class Staff {
String newEmployee = ""; String newEmployee = "";
try { try {
Statement myStatement = dbConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); Statement myStatement = dbConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
myStatement.executeUpdate("insert into Employees (first_name,last_name,isManager,email,phoneNumber,wage)" + if (email.equals("empty")) {
" values ('" + firstName + "','" + lastName + "'," + isManager + ",'" + email + "','" + myStatement.executeUpdate("insert into Employees (first_name,last_name,isManager,email,phoneNumber,wage)" +
phoneNumber + "'," + wage + ")"); " values ('" + firstName + "','" + lastName + "'," + isManager + ", null,'" +
phoneNumber + "'," + wage + ")");
} else {
myStatement.executeUpdate("insert into Employees (first_name,last_name,isManager,email,phoneNumber,wage)" +
" values ('" + firstName + "','" + lastName + "'," + isManager + ",'" + email + "','" +
phoneNumber + "'," + wage + ")");
}
ResultSet myRs = myStatement.executeQuery("select * from Employees where first_name='" + firstName ResultSet myRs = myStatement.executeQuery("select * from Employees where first_name='" + firstName
+ "' and last_name='" + lastName + "'"); + "' and last_name='" + lastName + "'");
if (myRs.last()) { if (myRs.last()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment