OF: bluesky35 (blue) development environment:. Windows2000 Eclipse3.0 Tomcat4.1.27 Oracle9i1 configuration first
Name> RemoveabandONEDTimeOut name>
Import java.io. *;
Import javax.servlet.ServletException; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletRequest; import javax.servlet.http.httpservletResponse;
Import java.sql. *; import javax.sql. *; import javax.naming. *; public class servlet extends httpservlet {
Protected Void Dopost (httpservletRequest Request, HttpservletResponse Response) throws servletexception, ioException {
// DATABEAN SAMPLE = New DataBean (); string txtName = Request.getParameter ("txtName"); string txtpassword = request.getParameter ("txtpassword"); printwriter out = response.getwriter ();
try {boolean loginSuccessd = false; String url_ = "192.168.0.1:1521:oracle"; String id_ = "abc"; String pass_ = "123"; Connection conn = null; Statement stmt = null; Context initContext = new InitialContext ( ); Context envcontext = (context) INITCONTEXT.LOOKUP ("java: / comp / ENV"); DataSource DS = (DataSource) EnvContext.lookup ("JDBC / Waporacle"); conn = ds.getConnection (); stmt = conn .createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet res = stmt.executeQuery ( "select * from test"); while (res.next ()) {String usr = res.getString ( "USERNAME"); String pwd = Res. GetString ("password"); if (usr! = null && us) && pop.equals ()) {loginsuccessd = true; Break;}} IF LoginsuccessD == True) {Out.println ("Welcome !!!");} else {output.println ("UserName or Password Is Not Correct");} //request.setttribute ("Bean Object ", sample);} catch (namingexception ne) {system.out.println (" Initial DataSource Error); Ne.PrintStackTrace ();} catch (sqlexception e) {system.out.println ("Oracle:" E); E.PrintStackTrace (); out.println ("Connection Full!");}}} bean middle code as follows: package sampleServlet; public class data = ";"; Public string getusername () {return this.username;
public void setUserName (String username) {this.username = username;} public String getPassword () {return this.password;} public void setPassword (String password) {this.password = password;}} Comming.html follows: