import java.sql.*;
import java.util.*;
public class Employee {
private long id;
private String firstName;
private String lastName;
private String title;
private String address;
private String city;
public static void main(String[] args) {
ResultSet rs;
try {
Employee employee, newEmployee;
List list;
//to test search mehtod
list = Employee.search( " ");
System.out.println( "original--------------------------- ");
for (int i=0; i <list.size();i++) {
employee = (Employee) list.get(i);
System.out.printf( "%s\n ",employee);
}
//to test add method
newEmployee = new Employee();
newEmployee.setFirstName( "New ");
newEmployee.add();
list = Employee.search( " ");
System.out.println( "a new Employee added--------------------------- ");
for (int i=0; i <list.size();i++) {
employee = (Employee) list.get(i);
System.out.printf( "%s\n ",employee);
}
//to test the load method
long employeeId;
employeeId = newEmployee.getId();
newEmployee = new Employee();
newEmployee.setId(employeeId);
newEmployee.load();
System.out.printf( "%s\n ",newEmployee);
//to test update method
newEmployee.setFirstName( "updated ");
newEmployee.update();
//System.out.printf( "%s\n ",employee);
list = Employee.search( " ");
System.out.println( "the new Employee updated--------------------------- ");
for (int i=0; i <list.size();i++) {
employee = (Employee) list.get(i);
System.out.printf( "%s\n ",employee);
}
//to test delete method
newEmployee.delete();
list = Employee.search( " ");
System.out.println( "the new Employee deleted--------------------------- ");
for (int i=0; i <list.size();i++) {
employee = (Employee) list.get(i);
System.out.printf( "%s\n ",employee);
}
} catch (Exception ex) {
System.out.println( "Exeption: " + ex.getMessage());