beautypg.com

Modifying the employee.java file – HP Integrity NonStop J-Series User Manual

Page 76

background image

After modification, the EmployeeDao.java file appears as:

package com.hp.empinfo.service;

import java.sql.SQLException;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import com.hp.empinfo.domain.Employee;
import com.hp.empinfo.domain.EmployeeRowMapper;

public class EmployeeDao extends JdbcDaoSupport {

public Employee getDetail(int empid) throws SQLException {

Employee employee;
employee = (Employee) getJdbcTemplate().queryForObject(
"select * from employee where emp_id =?",
new Object[] { empid }, new EmployeeRowMapper());
return employee;
}
public void insertDetail(int empid, String firstname, String lastname,
int age, String email) throws SQLException {
getJdbcTemplate().update("insert into employee values(?,?,?,?,?)",
new Object[] { empid, firstname, lastname, age, email });
}

public String deleteEmployee(int empid) {

getJdbcTemplate().update("delete from employee where emp_id= ?",
new Object[] { empid });
return "Employee deleted";
}
}

Modifying the Employee.java File

You must modify the Employee.java file in the com.hp.empinfo.domain package to add a
property record, which can be used to distinguish between the retrieve and delete request.

Modify the POJO to add a new property rord and its getter and setters.

After modification, the Employee.java file appears as:

package com.hp.empinfo.domain;

public class Employee implements java.io.Serializable {

private int empid;;
private String firstname;
private String lastname;
private int age;
private String email;

private String rord;

public String getRord() {
return rord;
}
public void setRord(String rord) {
this.rord = rord;
}
public int getEmpid() {
return empid;
}
public void setEmpid(int empid) {
this.empid = empid;
}
public String getFirstname() {
return firstname;
}
public void setFirstname (String firstname) {
this. firstname= firstname;

76

Spring Framework

This manual is related to the following products: