Ok so i have a little problem which i cant seem to figure out
this is what i have:
The constructor loads my method that loads a list of employee to show in jTable, but when i place that method in my button it doesn't do anything
This is my code:
Method that loads the employees from my DBEngine Class
public void viewEmpleados(){
try {
DBEngine dbe = new DBEngine();
dbe.getEmployee();
data = dbe.getEmployee();
header = new Vector<String>();
header.add("Id");
header.add("Fname");
header.add("Lname");
header.add("Departamento");
header.add("Puesto");
} catch (Exception ex) {
}
}
This is the DBEngine.getEmployee method
public Vector getEmployee()throws Exception{
Vector<Vector<String>> employeeList =
new Vector<Vector<String>>();
dbConnection(); //My db connection
String empQuery = "Select idEmpleado,fname,lname,dep From Empleados;";
rs = st.executeQuery(empQuery);
while(rs.next()){
Vector<String> employee = new Vector<String>();
employee.add(rs.getString(1));
employee.add(rs.getString(2));
employee.add(rs.getString(3));
employee.add(rs.getString(4));
employeeList.add(employee);
}
con.close();
return employeeList;
}
I want my jTable to refresh each time i press the button "View Employee" after i add an employee from a form, or when i add it directly from Postgresql
Thanks if anyone can help
:/
:)