package RDG;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import javax.sql.DataSource;
import org.postgresql.ds.PGSimpleDataSource;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Marcel
 */
public class Class {
    Integer class_id;
    String class_name;

    public Integer getClass_id() {
        return class_id;
    }

    public void setClass_id(Integer class_id) {
        this.class_id = class_id;
    }

    public String getClass_name() {
        return class_name;
    }

    public void setClass_name(String class_name) {
        this.class_name = class_name;
    }

    @Override
    public String toString() {
        return "Class{" + "class_id=" + class_id + ", class_name=" + class_name + '}';
    }
    
    /**
     * check if class w/ this id exists
     * @param class_id  
     * @throws SQLException
     * @return boolean if class w/ this id exists
     */
    public static boolean exists(int class_id) throws SQLException {
        PreparedStatement s = DbContext.getConnection().prepareStatement("SELECT * from classes WHERE class_id=?");
        s.setInt(1, class_id);
        return s.executeQuery().next();
    }
}
