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 PassengerType {
    Integer passenger_type_id;
    String passenger_type_name;

    public Integer getPassenger_type_id() {
        return passenger_type_id;
    }

    public void setPassenger_type_id(Integer passenger_type_id) {
        this.passenger_type_id = passenger_type_id;
    }

    public String getPassenger_type_name() {
        return passenger_type_name;
    }

    public void setPassenger_type_name(String passenger_type_name) {
        this.passenger_type_name = passenger_type_name;
    }

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