-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidate.java
More file actions
29 lines (24 loc) · 904 Bytes
/
Validate.java
File metadata and controls
29 lines (24 loc) · 904 Bytes
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
import java.sql.*;
public class Validate {
public static boolean checkUser(String username,String password)
{
boolean st = false;
try {
//loading drivers for mysql
Class.forName("com.mysql.jdbc.Driver");
//creating connection with the database
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/exampledb","root","demoLogin");
PreparedStatement ps = con.prepareStatement("select * from login1 where username=? and password=?");
ps.setString(1, username);
ps.setString(2, password);
ResultSet rs =ps.executeQuery();
st = rs.next();
return st;
}
catch(Exception e) {
e.printStackTrace();
return !st;
}
// return st;
}
}