-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateUserTask.java
More file actions
43 lines (38 loc) · 1.11 KB
/
UpdateUserTask.java
File metadata and controls
43 lines (38 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package mnregapkg;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
public class UpdateUserTask {
public void allowButton(int userid) {
// TODO Auto-generated method stub
boolean yn = false;
DBManager manager = new DBManager();
Connection localCon=manager.getConnection();
PreparedStatement preSt=null;
String query=("UPDATE user SET user.name=request.updatedname,user.email=request.updatedemail WHERE userid=?;");
String delquery=("DELETE FROM request WHERE userid=? ");
try {
preSt=localCon.prepareStatement(query);
preSt.setInt(1, userid);
yn=preSt.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(yn){
System.out.println("successfully updated");
try {
preSt=localCon.prepareStatement(delquery);
preSt.setInt(1, userid);
boolean delyn = preSt.execute();
if(delyn){
System.out.println("that request is deleted from request");
}
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}