/*
* Created on 2005-9-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package fibernews.action;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
import fibernews.framework.db.*;
import fibernews.beans.Employee;
import fibernews.util.function.HandleString;
import fibernews.framework.logging.Logger;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ListEmpAction extends Action {
List list ;
public String process(HttpServletRequest request, HttpServletResponse response) {
Connection conn=DBHelper.getConnection();
Statement st=null;
PreparedStatement pst=null;
ResultSet rs=null ;
String query=HandleString.toChinese(request.getParameter("query"));
if ((query==null)||query.trim().equals("")) query="lmsun";
try{
String sql="select * from employee_email where name like '%"+query+"%' or email like '%"+query+"%'" ;
//st=conn.createStatement();
pst=conn.prepareStatement(sql);
rs=pst.executeQuery();
list=new ArrayList();
Employee emp;
while (rs.next()){
emp=new Employee();
emp.setId(rs.getString("id"));
emp.setEmployee_bh(rs.getString("employee_bh"));
emp.setName(rs.getString("name"));
emp.setEmail(rs.getString("email"));
emp.setDepartment1(rs.getString("department1"));
emp.setDepartment2(rs.getString("department2"));
emp.setDepartment3(rs.getString("department3"));
list.add(emp);
}
}
catch (Exception e) {
System.out.println("Error Connecting to catalog DB: " + e.toString());
}
finally {
DBHelper.close(rs,pst,conn);
}
request.setAttribute("empList",list);
return "/intra/query/emailbook.jsp";
}
public static void main(String[] args)
{
ListEmpAction empaction = new ListEmpAction();
System.out.print("End");
}
}
posted on 2005-09-27 13:21
my java 阅读(311)
评论(0) 编辑 收藏