Home » Java » Link to the database and display the form

Link to the database and display the form

Package wx05; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; public class BaseUserInfoDao public List (getAllinfo) {{
List retval=new ArrayList (try); {try {Class.forName ("Connection"); connection = DriverManager.getConnection ("Statement"); createStatement = connection.createStatement; rs = createStatement.executeQuery (ResultSet) ("select * from student"); while (rs.next) ({String)
UserName = rs.getString ("UserName"); int UserId = rs.getInt ("UserId"); String UserPassword = rs.getString ("UserPassword"); BeanUserInfoBean beanUserInfoBean = new BeanUserInfoBean (UserName, UserId, UserPassword); retval.add (beanUserInfoBean) catch (SQLException}};
E TODO Auto-generated catch (blocke.printStackTrace) {//}}); catch (ClassNotFoundException E) TODO Auto-generated catch blocke.printStackTrace {// (return retval);};}}public class BeanUserInfoBean {String UserName @Overridepublic String toString ({return);
"BeanUserInfoBean [UserName=" + UserName + "UserId=" + UserId + "UserPassword=" + UserPassword +];}public BeanUserInfoBean (String UserName, int userId, String userPassword) ({super); UserName = UserName; UserId = userId; UserPassword = userPassword;}int
UserId; String UserPassword; public String getUserName ({return) UserName;}public void setUserName (String userName) {UserName = userName;}public int getUserId ({return) UserId;}public void setUserId (int userId) {UserId = userId;}public String (getUserPassword)
{return UserPassword;}public void setUserPassword (String userPassword) {UserPassword = userPassword;}}public class Servlet extends HttpServlet {private static final long serialVersionUID = 1L; / * * * @see HttpServlet#HttpServlet (Servlet) / public (super) {();
Auto-generated constructor / / TODO stub * @see HttpServlet#doGet}/** (HttpServletRequest request, HttpServletResponse response) */protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}/** * @see
HttpServlet#doPost (HttpServletRequest request, HttpServletResponse response) */protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {BaseUserInfoDao baseUserInfoDao = new BaseUserInfoDao (List);
Allinfo = baseUserInfoDao.getAllinfo (request.getSession); (.SetAttribute) (allinfo, allinfo); response.sendRedirect ("show.jsp");}}<%@ page language= "Java" contentType= "text/html; charset=ISO-8859-1" pageEncoding= "ISO-8859-1" taglib uri= http://java.sun.com/jsp/jstl/core "<%@% >"
Prefix= C% >


ID password user name