forked from PiyushJT/Dating_Mania_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
89 lines (68 loc) · 2.3 KB
/
Project.java
File metadata and controls
89 lines (68 loc) · 2.3 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.sql.*;
import db.*;
import logs.*;
import model.*;
import session.*;
import util.*;
public class Project {
public static void main(String[] args) {
Log.S("System Started");
// Database Initialization
String url = "jdbc:postgresql://localhost:5432/Dating_Mania";
String user = "postgres";
String password = "";
// Supabase connection details
String host = "db.swjthzmlrxqktynhouga.supabase.co";
String database = "postgres";
String port = "5432";
user = "postgres";
password = "dtydhtb";
// Construct the full JDBC URL
url = "jdbc:postgresql://" + host + ":" + port + "/" + database;
// Connect to Database
try {
Class.forName("org.postgresql.Driver");
DatabaseIO.connection = DriverManager.getConnection(url, user, password);
Log.S("Connected to PostgreSQL successfully!");
// Load Current model.User data if Logged in.
CurrentUser.initUserData();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
Utility.println("JDBC Driver not found.", 7);
Log.E("JDBC Driver not found.");
return;
}
catch (SQLException e) {
Utility.println("Connection failed.", 7);
Log.E("Connection failed.");
e.printStackTrace();
return;
}
catch (Exception e) {
Utility.println("Database was unable to load! :(", 7);
Log.E("Database was unable to load! :(");
return;
}
// Load All Users
try {
User.users = DatabaseIO.getAllUsers();
Log.DB("All Users loaded successfully!");
}
catch (SQLException e) {
Utility.println("Database was unable to load! :(", 7);
Log.E("Users not loaded");
return;
}
// Welcome Screen
Utility.printWelcome();
// Open Login Menu if not already logged in
if (CurrentUser.data == null)
Utility.openLoginMenu();
else {
Utility.printLines(2);
Utility.println("Welcome back " + CurrentUser.data.getName() + ".", 3);
Utility.openMainMenu();
}
}
}