Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RegisterCustomer() {
- try {
- // recreate the connection if needed
- if (this.connect == null || this.connect.isClosed()) {
- // change the DB Path
- this.connect = DriverManager.getConnection("jdbc:sqlite:Application.db");
- }
- //recreate the statement if needed
- if (this.statement == null || this.statement.isClosed()) {
- this.statement = this.connect.createStatement();
- }
- } catch (SQLException e) {
- System.out
- .println("Failed to connect to the database");
- throw new RuntimeException(e);
- }
- String username = user.getText();
- char[] pass = password.getPassword();
- String password = new String(pass);
- char[] passConfirm = confirmPass.getPassword();
- String passwordConfirm = new String(passConfirm);
- String firstName = FirstName.getText();
- String lastName = LastName.getText();
- String email = Email.getText();
- int age = Integer.parseInt(Age.getText());
- try {
- PreparedStatement preparedStatement = this.connect.prepareStatement("INSERT INTO CUSTOMER (USERNAME, PASSWORD, FIRSTNAME, LASTNAME, EMAIL, AGE) VALUES (?,?,?,?,?,?)");
- preparedStatement.setString(1, username);
- preparedStatement.setString(2, password);
- preparedStatement.setString(3, firstName);
- preparedStatement.setString(4, lastName);
- preparedStatement.setString(5, email);
- preparedStatement.setInt(6, age);
- }
- catch (Exception e) {
- System.out.println("Error retrieving customer information");
- throw new RuntimeException(e);
- }
- }
- public void RegisterSeller() {
- try {
- // recreate the connection if needed
- if (this.connect == null || this.connect.isClosed()) {
- // change the DB Path
- this.connect = DriverManager.getConnection("jdbc:sqlite:Application.db");
- }
- //recreate the statement if needed
- if (this.statement == null || this.statement.isClosed()) {
- this.statement = this.connect.createStatement();
- }
- } catch (SQLException e) {
- System.out
- .println("Failed to connect to the database");
- throw new RuntimeException(e);
- }
- String username = user.getText();
- char[] pass = password.getPassword();
- String password = new String(pass);
- char[] passConfirm = confirmPass.getPassword();
- String passwordConfirm = new String(passConfirm);
- String firstName = FirstName.getText();
- String lastName = LastName.getText();
- String email = Email.getText();
- int age = Integer.parseInt(Age.getText());
- try {
- PreparedStatement preparedStatement = this.connect.prepareStatement("INSERT INTO SELLER (USERNAME, PASSWORD, FIRSTNAME, LASTNAME, EMAIL, AGE) VALUES (?,?,?,?,?,?)");
- preparedStatement.setString(1, username);
- preparedStatement.setString(2, password);
- preparedStatement.setString(3, firstName);
- preparedStatement.setString(4, lastName);
- preparedStatement.setString(5, email);
- preparedStatement.setInt(6, age);
- }
- catch (Exception e) {
- System.out.println("Error retrieving customer information");
- throw new RuntimeException(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement