public ResultSet retryResult(String query) {
        boolean passed = false;
        Statement statement = null;
        ResultSet result = null;

        while (!passed) {
            try {
                //Connection connection = getConnection();
                this.connection = this.getConnection();
                statement = this.connection.createStatement();
                result = statement.executeQuery(query);
                passed = true;
                return result;
            } catch (SQLException ex) {
                if (ex.getMessage().toLowerCase().contains("locking") || ex.getMessage().toLowerCase().contains("locked")) {
                    passed = false;
                } else {
                    this.writeError("Error at SQL Query: " + ex.getMessage(), false);
                }
            }
        }

        return null;
    }