Search in sources :

Example 6 with WorkersTable

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

the class SQLDatabaseConnection method setPasswordWorker.

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

Aggregations

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