-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnecter.java
More file actions
38 lines (29 loc) · 1.15 KB
/
Copy pathConnecter.java
File metadata and controls
38 lines (29 loc) · 1.15 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
package DB_Testing;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class Connector {
public static Connection Connect() throws SQLException{
return DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=test_Database;user=Camelia;password=test; encrypt=true; trustServerCertificate=true");
}
public static String Login(){
String usertype = JOptionPane.showInputDialog("Please enter your usertype: ");
String username = JOptionPane.showInputDialog("Enter Username");
String password = JOptionPane.showInputDialog("Enter Password");
if(usertype.equals("admin")){
if(username.equals("admin") && password.equals("admin")){
return "admin";
}
}
else if(usertype.equals("user")){
if(username.equals("user") && password.equals("user")){
return "user";
}
}
else{
JOptionPane.showMessageDialog(null, "Login Failed");
}
return "";
}
}