-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserDoc.java
59 lines (45 loc) · 1.71 KB
/
UserDoc.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
package UserClasses;
import DbClasses.DB;
import java.sql.*;
public class UserDoc {
public static int save(String name, String password, String email, String address, String city, String contact){
int status=0;
try{
Connection con=DB.getConnection();
PreparedStatement ps=con.prepareStatement("insert into users(name,password,email,address,city,contact) values(?,?,?,?,?,?)");
ps.setString(1,name);
ps.setString(2,password);
ps.setString(3,email);
ps.setString(4,address);
ps.setString(5,city);
ps.setString(6,contact);
status=ps.executeUpdate();
con.close();
}catch(Exception e){System.out.println(e);}
return status;
}
public static int delete(int id){
int status=0;
try{
Connection con=DB.getConnection();
PreparedStatement ps=con.prepareStatement("delete from users where id=?");
ps.setInt(1,id);
status=ps.executeUpdate();
con.close();
}catch(Exception e){System.out.println(e);}
return status;
}
public static boolean validate(String name,String password){
boolean status=false;
try{
Connection con=DB.getConnection();
PreparedStatement ps=con.prepareStatement("select * from users where name=? and password=?");
ps.setString(1,name);
ps.setString(2,password);
ResultSet rs=ps.executeQuery();
status=rs.next();
con.close();
}catch(Exception e){System.out.println(e);}
return status;
}
}