Search in sources :

Example 6 with CustomersTable

use of SQLDatabase.SQLDatabaseEntities.CustomersTable in project SmartCity-Market by TechnionYP5777.

the class SQLDatabaseConnection method setPasswordCustomer.

@Override
public void setPasswordCustomer(String username, String newPassword) throws CriticalError, ClientNotExist {
    log.debug("SQL Public setPasswordCustomer: Customer: " + username + " sets password.");
    if (!isCustomerExist(username)) {
        log.debug("SQL Public setPasswordCustomer: no such customer with username: " + username);
        throw new ClientNotExist();
    }
    try {
        // START transaction
        connectionStartTransaction();
        //Write part of transaction
        //updating password
        assignPasswordToRegisteredClient(new CustomersTable(), username, newPassword);
        log.debug("SQL Public setPasswordCustomer: Success setting password for username: " + username);
        // END transaction
        connectionCommitTransaction();
    } catch (SQLDatabaseException e) {
        connectionRollbackTransaction();
        throw e;
    } finally {
        connectionEndTransaction();
    }
}
Also used : CustomersTable(SQLDatabase.SQLDatabaseEntities.CustomersTable) SQLDatabaseException(SQLDatabase.SQLDatabaseException)

Aggregations

CustomersTable (SQLDatabase.SQLDatabaseEntities.CustomersTable)6 SQLDatabaseException (SQLDatabase.SQLDatabaseException)6 SQLException (java.sql.SQLException)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1