-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
484b49e
commit f2c3d6c
Showing
3 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
package controller; | ||
import java.sql.*; | ||
|
||
public class Controller { | ||
Class.forName("com.mysql.jdbc.Driver"); | ||
Connection connect = DriverManager.getConnection("srv-bdens.insa-toulouse.fr", "projet_gei_011", "shu6AeNg"); | ||
Statement state = connect.createStatement(); | ||
|
||
Connection connect = Controller.getConnection(srv-bdens.insa-toulouse.fr, projet_gei_011, shu6AeNg); | ||
Statement statement = connect.createStatement(); | ||
String query = "SELECT * FROM User"; | ||
public static void logIn(String text, char[] password) { | ||
|
||
public static int logIn(String email char[] password) { | ||
int logStatus = 0; | ||
String loginAttempt = "EXISTS (SELECT * FROM USER WHERE Email = " + email + " AND Password = " + password + ")"; | ||
} | ||
public static void createNewUser(String firstName, String lastName, String email, String password, boolean isNeeder, boolean isVolunteer, boolean isValidator) { | ||
public static int createNewUser(String firstName, String lastName, String email, String password, boolean isNeeder, boolean isVolunteer, boolean isValidator) { | ||
String createUserAttempt = "EXISTS (SELECT * FROM USER WHERE EMAIL = " + email + ")"; | ||
ResultSet userExists = state.executeQuery(createUserAttempt); | ||
if (userExists != null){ | ||
system.out.println("User already exists"); | ||
return 1; | ||
} | ||
String userType = ""; | ||
if (isNeeder) { | ||
userType = "Needer"; | ||
} else if (isVolunteer) { | ||
userType = "Volunteer"; | ||
} else if (isValidator) { | ||
userType = "Validator"; | ||
} | ||
String userCreationQuery = "INSERT INTO USER (FirstName, LastName, Email, Password, UserType) VALUES (" + firstName + ", " + lastName + ", " + email + ", " + password + ", " + userType + ")"; | ||
ResultSet userCreation = state.executeQuery(userCreationQuery); | ||
return 0; | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters