Notes, summaries, assignments, exams, and exercises for Computer science for University

Java Hibernate DAO for Student Management (AlunoDAO)

Computer science5.2 KB

AlunoDAO.java

import java.util.List;

import model.Aluno;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

import util.HibernateUtil;

public class AlunoDAO {

Validating a User

public boolean validaUsuario(String login, String senha) {
HibernateUtil.getSession();
Session session = ...;
Transaction tx = session.beginTransaction();

String query = "from Aluno where login = ? and senha = ?";

List<Aluno> lista = session.createQuery(query)
.setString(0, login)
.setString(1, senha)
.list();

tx.commit();

Aluno aluno = new Aluno();
if (lista.size() >= 1) {
return true;
} else {
return false;
}
}

Listing All Students

/**
* @return
*/
public List<Aluno> list() {
HibernateUtil.getSession(

...
Continue reading "Java Hibernate DAO for Student Management (AlunoDAO)" »

AlunoDAO.java: Java Hibernate DAO for Student Management

Computer science3.69 KB

AlunoDAO.java

import java.util.List;

import model.Aluno;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

import util.HibernateUtil;

public class AlunoDAO {

Validating a User

public boolean validaUsuario(String login, String senha) {
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();

String query = "from Aluno where login = ? and senha = ?";

List<Aluno> lista = session.createQuery(query)
.setString(0, login)
.setString(1, senha)
.list();

tx.commit();

Aluno aluno = new Aluno();
if(lista.size() >= 1){
return true;
}else{
return false;
}
}

Listing Students

/**
*
* @return
*/
public List<Aluno> listar() {
Session session = HibernateUtil....

Continue reading "AlunoDAO.java: Java Hibernate DAO for Student Management" »

Session Layer Protocol: SPDU Exchange, Tokens and Dialogue

Computer science2.73 KB

Session Layer Protocol and SPDU Exchange

The session protocol establishes the rules for exchanging data and control information between peer entities using a session transport connection. The abstract session protocol machine communicates with the user through a SSAP (Session Service Access Point) via the exchange of session service primitives, and with the supplier via a TSAP (Transport Service Access Point).

The relationship between the exchange of primitives and the procedures of the protocol is as follows:

  • If the machine receives a Session Protocol Data Unit (SPDU) delivered by the supplier (transport layer), an indication or confirmation of the user service is generated (for example, an early indication or confirmation).
  • If the user sends
...
Continue reading "Session Layer Protocol: SPDU Exchange, Tokens and Dialogue" »

Common Gateway Interface (CGI) and Web Server Interaction

Computer science3.5 KB

What is a Common Gateway Interface (CGI)?

A CGI (Common Gateway Interface) is a program that runs in real time on a Web Server in response to a request from a browser. When this happens, the Web Server executes a child process to receive the data sent by the user (if it exists), makes some silky sheets of the same data available as environment variables, and captures the output of the program to send a response to the browser. The CGI's purpose is to provide intelligence and interactivity to a website.

Basic CGI Structure in C Language

The basic body of a CGI in C language is:

/* Hello World Program */
/* Compile in Linux: gcc hello.c -o hello.cgi */

#include <stdio.h>

int main() {
    printf("Content-Type: text/html\n\n");
    printf("
...
Continue reading "Common Gateway Interface (CGI) and Web Server Interaction" »

Imagens Digitais: Introdução e Representação em Computação

Computer science2.34 KB

Imagens Digitais: Introdução

Com o avanço da tecnologia, há cada vez mais imagens empregadas ou utilizadas em sistemas computacionais. Essas aplicações estão presentes em páginas web, interfaces gráficas, softwares multimídia, jogos, programas educacionais, editoração eletrônica, computação gráfica, medicina e, principalmente, na área de processamento de imagens e visão computacional. Com isso, torna-se cada vez mais importante que o profissional e o usuário tenham conhecimento para melhor utilizar este recurso.

Representação de Imagens Digitais

Para entender melhor como as imagens são armazenadas, veremos como as imagens são representadas digitalmente. Representar uma imagem é modelá-la de forma que seus dados possam...

Continue reading "Imagens Digitais: Introdução e Representação em Computação" »

MFS File System Operations in C

Computer science3.59 KB

Code fragment likely from mfs_readdir:


int inodo_root_previo = get_inodo_previo(fs, dir->path); // obtain prior entry inode
inode_read(fs, &ino_previo, inodo_root_previo);
// Checking to see if what we are reading is a directory or not, and storing in variables
if (inodo_root_previo != -1) {
    if (inodo_root_previo > 0)
        root_is_dir = is_dir(fs, &ino_previo, name(fs, dir->num_inodo));
    else
        root_is_dir = is_dir(fs, &ino_previo, dir->path);
    if (root_is_dir == 0) {
        if (inodo_root_previo > 0) {
            strcpy(entry->d_name, name(fs, dir->num_inodo)); // assign the name of the entry
        } else {
            strcpy(entry->d_name, dir->path); // Assign the name of the
...
Continue reading "MFS File System Operations in C" »

8086 Microprocessor Interrupts: Hardware, Software, and Exceptions

Computer science3.1 KB

Types of Interrupts in the 8086 Microprocessor

The 8086 microprocessor utilizes various mechanisms to handle external events and internal errors. These mechanisms are categorized into three primary types of interrupts: Hardware, Software, and Internal (Exceptions).

1. Hardware Interrupts

Hardware interrupts are generated by external hardware devices to request service from the microprocessor. The 8086 supports two hardware interrupt pins:

  • INTR (Interrupt Request)

    This is a maskable interrupt, meaning it can be enabled or disabled using the IF (Interrupt Flag) in the flag register. When an external device wants to interrupt the microprocessor, it sends a signal on the INTR pin.

    The 8086 acknowledges the interrupt if the IF flag is set, and the INTA

...
Continue reading "8086 Microprocessor Interrupts: Hardware, Software, and Exceptions" »

8086 Microprocessor Execution Unit Architecture Explained

Computer science2.23 KB

Execution Unit (EU) of 8086 Architecture

The Execution Unit (EU) is a fundamental component of the 8086 microprocessor, responsible for the actual execution of instructions. It performs arithmetic and logical operations, manages data flow, and controls internal registers.

Key Components of the EU

  • Arithmetic Logic Unit (ALU): The heart of the EU, performing all arithmetic (addition, subtraction, multiplication, division) and logical (AND, OR, NOT, XOR) operations. It processes data from registers and returns the results.
  • Registers: High-speed storage locations directly accessible by the CPU:
    • General-purpose: AX, BX, CX, DX for data storage.
    • Segment: CS, DS, ES, SS for memory addressing.
    • Pointer and Index: SP, BP, SI, DI for memory management.
    • Instruction
...
Continue reading "8086 Microprocessor Execution Unit Architecture Explained" »

10 Usability Heuristics for User Interface Design

Computer science2.46 KB

1. Visibility of System Status

The system should always keep users informed about what is going on, through appropriate feedback within a reasonable time.

2. Match Between System and the Real World

The system should speak the user's language, with words, phrases, and concepts familiar to the user, rather than system-oriented terms. Follow real-world conventions, making information appear in a natural and logical order.

3. User Control and Freedom

Users often choose system functions by mistake and will need a clearly marked "emergency exit" to leave the unwanted state without having to go through an extended dialogue. Support undo and redo.

4. Consistency and Standards

Users should not have to wonder whether different words, situations, or actions...

Continue reading "10 Usability Heuristics for User Interface Design" »