package RDG;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Marcel
 */
public class ClassesFinder {

    /**
     * selectAll classes
     * @return List of Class 
     */
    public static List<Class> selectAll() throws SQLException {
        List<Class> res = new ArrayList<>();
        PreparedStatement s = DbContext.getConnection().prepareStatement("SELECT * from classes");
        ResultSet rs = s.executeQuery();
        while (rs.next()) {
            Class tmp = new Class();
            tmp.setClass_id(rs.getInt("class_id"));
            tmp.setClass_name(rs.getString("class_name"));
            res.add(tmp);
        }
        return res;
    }
    
}
