package net.h4ckx0r.controlador;

import net.h4ckx0r.modelo.TipologiaSexo;

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

public class ControladorTipologiaSexo {
    public static List<TipologiaSexo> getAllSexos() {
        Connection conn = GestorConexiones.getConexion();
        List<TipologiaSexo> sexos = new ArrayList<>();

        try {
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery("SELECT * FROM tipologiaSexo");

            while (rs.next()) {
                sexos.add(new TipologiaSexo(rs.getInt("id"), rs.getString("descripcion")));
            }

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return sexos;
    }
}
