package tutorialJava.examenes.examen20250509.controlador;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import tutorialJava.examenes.examen20250509.modelo.Sala;



public class ControladorSala {
	
	public static List<Sala> findAll() {
		List<Sala> lista = new ArrayList<Sala>();
		
		try {
			Connection conn = ConnectionManager.getConnection();
			Statement s = conn.createStatement();
			ResultSet rs = s.executeQuery("select * from sala");
			
			while (rs.next()) {
				Sala sala = new Sala();
				sala.setId(rs.getInt("id"));
				sala.setNombre(rs.getString("nombre"));
				sala.setCiudad(rs.getString("ciudad"));
				sala.setAforo(rs.getInt("aforo"));
				lista.add(sala);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return lista;
	}
}
