package br.dsc.upe.poli.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import br.dsc.upe.poli.banco.ConexaoFactory;
import br.dsc.upe.poli.basicas.Professor;

public class ProfessorDAO {

	private Connection connection;

	public ProfessorDAO() throws ClassNotFoundException, SQLException {
		connection = new ConexaoFactory().getConexao();
	}

	public void cadastrar(Professor professor) throws SQLException {
		PreparedStatement stmt;
		stmt = connection
				.prepareStatement("INSERT INTO PROFESSORES_TABLE (nome_professor, disciplina,identidade ) VALUES (?,?,?)");
		stmt.setString(1, professor.getNome());
		stmt.setString(2, professor.getDisciplina());
		stmt.setString(3, professor.getIdentidade());
		stmt.execute();
		stmt.close();

		PreparedStatement stmt1 = connection
				.prepareStatement("INSERT INTO VALIDACAO_TABLE (login, senha, identidade,tipo_usuario) VALUES (?,?,?,?)");
		stmt1.setString(1, professor.getLogin());
		stmt1.setString(2, professor.getSenha());
		stmt1.setString(3, professor.getIdentidade());
		stmt1.setString(4, "PROFESSOR");
		
		stmt1.execute();
		stmt1.close();
	}

}
