Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void vertodos(Connection conexion, JTextArea textArea) {
- String mensaje="";
- textArea.setText("");
- try {
- String sql = "select * from empleados";
- Statement sentencia = conexion.createStatement();
- ResultSet res = sentencia.executeQuery(sql);
- String cabecera= " EMP_NO APELLIDO OFICIO DIR FECHA_ALT SALARIO COMISION DEPT_NO\n ------- --------------- --------------- \n";
- textArea.append(cabecera);
- if (res.next())
- {
- do {
- String cadena=
- 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));
- textArea.append(cadena);
- }while (res.next());
- }
- else {
- textArea.append(" NO HAY EMPLEADO ");
- }
- } catch (SQLException e) {
- textArea.append(e.getMessage());
- //e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement