-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminTaskImp.java
81 lines (69 loc) · 2.04 KB
/
AdminTaskImp.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package mnregapkg;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
public class AdminTaskImp implements AdminTask{
public UserBean pullDataFromUser(int userid) {
// TODO Auto-generated method stub
System.out.println("in admintaskimp and values of gathered userid is"+userid);
UserBean userBean = null;
DBManager manager= new DBManager();
Connection localCon = manager.getConnection();
PreparedStatement preSt = null;
ResultSet rs = null;
String query= "SELECT* FROM user WHERE userid=?";
try {
preSt=localCon.prepareStatement(query);
preSt.setInt(1, userid);
rs = preSt.executeQuery();
System.out.println("got rs");
if(rs!=null){
while(rs.next()){
userBean = new UserBean();
userBean.setuserid(rs.getInt(1));
userBean.setusername(rs.getString(2));
userBean.setpassword(rs.getString(3));
userBean.setname(rs.getString(4));
userBean.setemail(rs.getString(5));
}
}else
System.out.println("no values recevied in rs");
}catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("sql exception at admintaskimp");
}
return userBean;
}
public void displayUserInformation(UserBean user) {
// TODO Auto-generated method stub
AdminUserView userview = new AdminUserView(user);
userview.setVisible(true);
}
public List pullAllUseridFromrequest() {
// TODO Auto-generated method stub
List list = null;
DBManager manager = new DBManager();
Connection localCon=manager.getConnection();
Statement st=null;
ResultSet rs=null;
st=manager.getStatement(localCon);
String query="SELECT userid FROM REQUEST";
rs=manager.executeSelectQuery(st, query);
if(rs!=null){
try {
while(rs.next()){
list = new ArrayList();
list.add(new Integer(rs.getInt(1)));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return list;
}
}