Public class logondataPoolAction extends action {
Public ActionForward Perform (ActionMapping ActionMApping, Actionform Actionform,
HttpservletRequest Request, httpservletResponse response) {
Try {Request.setCharacterencoding ("GBK");} catch (exception ex) {ex.printstacktrace ();}
/ / Define the variable of the database buffer pool
DataSource DataSource;
CONNECTION CONN;
PreparedStatement PreparedStmt;
ResultSet RS;
Try {
/ / Obtain the Data Buffer Pool of the Struts-Config file
DataSource = getDataSource (Request, "Logon");
CONN = DataSource.getConnection ();
// Create prepaaredStatement
PreparedStmt = conn.preparestatement ("SELECT * from logonuser where username =?"
"and userpassword =?");
/ / Get the username and password entered by the user
String name = Request.getParameter ("name"). Trim ();
String password = Request.getParameter ("password"). Trim ();
// If the username and password are correct, the steering display successfully logs in the information page, otherwise the turn to the failed login information page
PreparedStmt.setstring (1, name);
PreparedStmt.setString (2, Password);
RS = preparedStmt.executeQuery ();
String address = "";
IF (rs.next ()) {
Address = "Success";
} else {
Address = "failure";
}
// Turn off the database connection
CONN.CLOSE ();
Return (ActionMapping.FindForward (Address);
} catch (exception e) {
E.PrintStackTrace ();
Return (ActionMapping.FindForward ("Failure");
}
}
}
Specific application http://www.cnpoint.com