Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ReparacionesNoFacturadasUnClienteAction implements Action {
- /**
- * Proceso:
- *
- * - Pide el DNI del cliente
- *
- * - Muestra en pantalla todas sus averias no facturadas (status <>
- * 'FACTURADA'). De cada avería muestra su id, fecha, status, importe y
- * descripción
- */
- @Override
- public void execute() throws BusinessException {
- Console.println("\nListado de averías no facturadas de un cliente\n");
- String SQL = " select a.id, a.fecha, a.status,a.importe, a.descripcion " +
- " from taverias a,tvehiculos v,tclientes c " +
- " where a.status<>'FACTURADA' and a.vehiculo_id=v.id and v.cliente_id=c.id and c.dni=? ";
- //332198006
- Connection c = null;
- PreparedStatement pst = null;
- ResultSet rs = null;
- // Pedir datos
- String dni = Console.readString("Dni");
- try {
- c = Jdbc.getConnection();
- pst = c.prepareStatement(SQL);
- pst.setString(1, dni);
- //pst.executeUpdate();
- rs = pst.executeQuery();
- while(rs.next()) {
- Console.printf("\t%d %s %s %d %s\n",
- rs.getLong(1)
- , rs.getDate(2)
- , rs.getString(3)
- , rs.getInt(4)
- , rs.getString(5)
- );
- }
- } catch (SQLException e) {
- throw new RuntimeException(e);
- } finally {
- Jdbc.close(rs, pst, c);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement