Modifying the employeedao.java file, Modifying the, Employeedao.java – HP Integrity NonStop H-Series User Manual
Page 444: File

int age, String email) throws SQLException ;
/**Deleting Employee corresponding to given employeeId**/
public String deleteEmployee(int empid) throws SQLException;
/**Checking whether the employee corresponding to provided employeeId already exists in the database**/
public Employee checkEmp(int empid)throws SQLException;
}
Modifying the
EmployeeDao.java
File
Modify the
EmployeeDao.java
file in
com.hp.empinfo.service
package to add a new
method
checkEmp(int empid)
for checking whether the employee with the given
empid
already exists.
After modification, the
EmployeeDao.java
file must appear as:
package com.hp.empinfo.service;
import java.sql.SQLException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import com.hp.empinfo.domain.Employee;
import com.hp.empinfo.domain.EmployeeRowMapper;
public class EmployeeDao extends JdbcDaoSupport implements IEmployeeDao {
public Employee getDetail(int empid) throws SQLException {
Employee employee;
employee = (Employee) getJdbcTemplate().queryForObject(
"select * from employee where empid =?",
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 empid= ?",
new Object[] { empid });
return "Employee deleted";
}
public Employee checkEmp(int empid) throws SQLException {
try{
Employee employee ;
employee = (Employee) getJdbcTemplate().queryForObject(
"select * from employee where empid =?",
new Object[] { empid }, new EmployeeRowMapper());
return employee;
}
catch (final EmptyResultDataAccessException e) {
return null;
}
}
444
Integrating MyFaces into Spring