HP Integrity NonStop J-Series User Manual
Page 103

}
public void setFirstname (String firstname) {
this. firstname= firstname;
}
public String getLastname () {
return lastname;
}
public void setLastname (String lastname) {
this. lastname= lastname;
}
public int getAge () {
return age;
}
public void setAge (int age) {
this. age= age;
}
public String getEmail () {
return email;
}
public void setEmail (String email) {
this. email= email;
}
}
Creating Data Access Object Implementation for JDBC
To run the Data Access Object (DAO) implementation for JDBC, complete the following steps:
1.
Create a com.hp.empinfo.service package and an EmployeeDao class under the
com.hp.empinfo.service
package, as described in
“Creating the Controller for EmpInfo”
. This will contain the logic for handling Employee Database Transactions.
2.
Modify the EmployeeDao.java class file to add the function for inserting employee details.
After modification, the EmployeeDao.java file must appear as:
package com.hp.empinfo.service;
import java.sql.SQLException;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
public class EmployeeDao extends JdbcDaoSupport{
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});
}
}
Creating and Modifying Supporting Views to Display Business Data
To create and modify supporting views to display business data, create the JSP files to create the
view by completing the following steps:
1.
Create the insertresult.jsp file in the Empinfo/WebContent/Web-INF/jsp directory
as described in
“Creating the index.jsp File” (page 80)
2.
Modify the insertresult.jsp file to provide a link to the insert.jsp page.
After modification, the insertresult.jsp file must appear as:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
Overview of EmpInfo 103