beautypg.com

Creating the rowmapper class – HP Integrity NonStop H-Series User Manual

Page 133

background image




Employee Email Id :

">Back

5.

Create the

deleteresult.jsp

file in the

EmpInfo/WebContent/WEB-INF/jsp

directory,

as described in the

Creating the

index.jsp

File

section.

6.

Modify the

deleteresult.jsp

file to remove the details of an employee record from the

JSP page.

After modification, the

deleteresult.jsp

file appears as:

<%@ include file="/WEB-INF/jsp/include.jsp"%>
<%@ taglib prefix="form"
uri="http://www.springframework.org/tags/form"%>



content="text/html; charset=ISO-8859-1">
Spring Getting Started - EmpInfo Application



Employee Deleted




${model.del}


>Back

Creating the RowMapper Class

The

RowMapper

class is used to map the retrieved

ResultSet

to the POJO class.

To create the

RowMapper

class, complete the following steps:

1.

Create a class

EmployeeRowMapper

in the

com.hp.empinfo.domain

package, as

described in the

Creating the Controller for EmpInfo

section.

2.

Modify the

EmployeeRowMapper.java

file to map

ResultSet

to the

Employee.java

class.

After modification, the

EmployeeRowMapper.java

file appears as:

package com.hp.empinfo.domain;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

public class EmployeeRowMapper implements RowMapper {

public Object mapRow(ResultSet rs, int rowcount) throws SQLException {
Employee employee=new Employee();
employee.setEmpid(rs.getInt(1));
employee.setFirstname(rs.getString(2));
employee.setLastname(rs.getString(3));
employee.setAge(rs.getInt(4));

Overview of EmpInfo

133

This manual is related to the following products: