Advertisement
claukiller

Untitled

Nov 6th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public class ReparacionesNoFacturadasUnClienteAction implements Action {
  2.  
  3. /**
  4. * Proceso:
  5. *
  6. * - Pide el DNI del cliente
  7. *
  8. * - Muestra en pantalla todas sus averias no facturadas (status <>
  9. * 'FACTURADA'). De cada avería muestra su id, fecha, status, importe y
  10. * descripción
  11. */
  12. @Override
  13. public void execute() throws BusinessException {
  14.  
  15. Console.println("\nListado de averías no facturadas de un cliente\n");
  16.  
  17. String SQL = " select a.id, a.fecha, a.status,a.importe, a.descripcion " +
  18. " from taverias a,tvehiculos v,tclientes c " +
  19. " where a.status<>'FACTURADA' and a.vehiculo_id=v.id and v.cliente_id=c.id and c.dni=? ";
  20.  
  21.  
  22. //332198006
  23. Connection c = null;
  24. PreparedStatement pst = null;
  25. ResultSet rs = null;
  26.  
  27. // Pedir datos
  28. String dni = Console.readString("Dni");
  29. try {
  30. c = Jdbc.getConnection();
  31. pst = c.prepareStatement(SQL);
  32. pst.setString(1, dni);
  33. //pst.executeUpdate();
  34.  
  35. rs = pst.executeQuery();
  36. while(rs.next()) {
  37. Console.printf("\t%d %s %s %d %s\n",
  38. rs.getLong(1)
  39. , rs.getDate(2)
  40. , rs.getString(3)
  41. , rs.getInt(4)
  42. , rs.getString(5)
  43. );
  44. }
  45.  
  46. } catch (SQLException e) {
  47. throw new RuntimeException(e);
  48. } finally {
  49. Jdbc.close(rs, pst, c);
  50. }
  51.  
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement