private static final String SELECT_ATRASO =
"SELECT NOME,DISCIPLINA FROM PROFESSOR WHERE STATUS= INDISPONIVEL";
public String selectAtrasos() throws SQLException, ClassNotFoundException {
String nome = null;
String disciplina = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = getConnection();
pstmt = super.prepareStatement( conn, SELECT_ATRASO );
rs = pstmt.executeQuery();
rs.setFetchSize( 1 );
if( rs.next() ) {
nome = rs.getString("NOME");
disciplina = rs.getString("DISCIPLINA");
} else {
throw new SQLException("");
}
} finally {
release(conn, pstmt, rs);
}
return nome+disciplina;
}
Após vem o Service...
public String selectAtrasos() throws ProfessorException {
String Atraso = null;
ProfessorDAO professorDAO = null;
try {
professorDAO = mysqlDAOFactory.getProfessorDAO();
professorDAO.getConnection();
Atraso = professorDAO.selectAtrasos();
} catch (SQLException e) {
e.printStackTrace();
throw new ProfessorException ("",e);
} catch (Exception e) {
e.printStackTrace();
throw new ProfessorException("",e);
}
return Atraso;
}
Professor = ProfessorService.getInstance().selectAtrasos();
Depois imprimir a variavel,
public void enviaDados () throws FileNotFoundException{
File Teste = new File("C:/Documents and Settings/rafaelabrito/Desktop/teste.txt");
PrintWriter saida = null;
saida = new PrintWriter(Teste);
saida.println(" Alunos: " + Aluno + " Professores: " + Professor+
" Funcionarios: "+Funcionario);
saida.close();
dispose();
}
Se alguém puder me dizer o que estou fazendo de errado! :/
Obrigado!!