-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidation.java
More file actions
37 lines (31 loc) · 875 Bytes
/
Copy pathValidation.java
File metadata and controls
37 lines (31 loc) · 875 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
30
31
32
33
34
35
36
37
package com.msc.dbms;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class Validation {
public static boolean loginValidity(String username, String password) {
boolean valid = false;
try {
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/java", "root", "2021239025");
PreparedStatement stmt = con.prepareStatement("select count(*)from ex where username=? and password=?");
stmt.setString(1,username);
stmt.setString(2,password);
ResultSet rs= stmt.executeQuery();
while(rs.next()) {
if(rs.getInt(1)>0)
{
valid = true;
}
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e) {
System.out.println(e);
}
return valid;
}
}