-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.java
59 lines (53 loc) · 1.27 KB
/
user.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package kamusi_proj;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
/**
*
* @author HP
*/
public class user {
static String username;
static String password;
public user(String a,String b)
{
username=a;
password=b;
}
public boolean userconnect()
{
Connection con=null;
boolean connected=false;
try
{
con=DBconnect.dbconnect();
String req="SELECT * FROM user where username='"+username+"' and password='"+password+"';";
Statement st=con.createStatement();
ResultSet result=st.executeQuery(req);
if(result.next())
{
String login="update user set status='on' where username='"+username+"' and password='"+password+"';";
st.executeUpdate(login);
connected=true;
}
else{
connected=false;
}
}
catch(Exception e)
{
e.printStackTrace();
}
DBconnect.connectclose(con);
return connected;
}
public static boolean userdisconnect()
{
return true;
}
}