Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. public static void vertodos(Connection conexion, JTextArea textArea) {
  2.        
  3.         String mensaje="";
  4.         textArea.setText("");
  5.         try {
  6.             String sql = "select * from empleados";
  7.             Statement sentencia = conexion.createStatement();
  8.             ResultSet res  = sentencia.executeQuery(sql);      
  9.             String cabecera= "  EMP_NO    APELLIDO        OFICIO        DIR     FECHA_ALT       SALARIO     COMISION        DEPT_NO\n  -------  --------------- --------------- \n";
  10.             textArea.append(cabecera);
  11.            
  12.             if (res.next())
  13.             {
  14.                 do {
  15.                 String cadena=         
  16.                 String.format("%8s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %n",  res.getInt(1) ,res.getString(2), res.getString(3), res.getInt(4), res.getDate(5), res.getFloat(6), res.getFloat(7), res.getInt(8));
  17.                                
  18.                 textArea.append(cadena);
  19.                
  20.                 }while (res.next());
  21.                
  22.             }
  23.             else {
  24.                 textArea.append(" NO HAY EMPLEADO ");
  25.             }          
  26.         } catch (SQLException e) {
  27.             textArea.append(e.getMessage());
  28.             //e.printStackTrace();
  29.         }  
  30.    
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement