Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. // Consultar Profesor
  2. @Override
  3. public Profesores consultarProfesores(String usuario, String password)
  4. {
  5. PreparedStatement pstm = null;
  6. ResultSet rs = null;
  7. Profesores profesores = null;
  8. try {
  9. String sql = "SELECT * FROM profesores WHERE lower(usuario) = ?";
  10. pstm = connection.prepareStatement(sql);
  11. pstm.setString(1, usuario);
  12. rs = pstm.executeQuery();
  13. if (rs.next()) {
  14. profesores = new Profesores(rs.getString("usuario"), rs.getString("password"), rs.getString("nombre"), rs.getString("apellidos"), rs.getString("nif"));
  15. profesores.setId(rs.getInt("id"));
  16. }
  17. } catch (SQLException e) {
  18.  
  19. } finally {
  20. try {
  21. if (pstm != null) {
  22. pstm.close();
  23. }
  24.  
  25. if (rs != null) {
  26. rs.close();
  27. }
  28. } catch (SQLException e) {
  29.  
  30. }
  31. }
  32. return profesores;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement