-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJdbcClass.java
More file actions
56 lines (50 loc) · 1.1 KB
/
JdbcClass.java
File metadata and controls
56 lines (50 loc) · 1.1 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
44
45
46
47
48
49
50
51
52
53
54
55
56
package EmployeM2Packege;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcClass {
Connection con=null;
public JdbcClass() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
}
catch(ClassNotFoundException e) {
System.out.println(e);
}
try {
con =DriverManager.getConnection("jdbc:mysql://localhost:3306/employeemanagement?user=root&password=Rewa@123");
}
catch(Exception e) {
System.out.println(e);
}
}
public boolean check(String user,String pass)
{
boolean isvalids=false;
try
{
PreparedStatement ps = con.prepareStatement("select * from login where username = ? and password = ?");
ps.setString(1, user);
ps.setString(2, pass);
ResultSet rs = ps.executeQuery();
if(rs.next()==true)
{
isvalids=true;
}
else
{
isvalids=false;
}
}
catch(SQLException e)
{
}
return isvalids;
}
public static void main(String[] args) {
JdbcClass j=new JdbcClass();
}
}