Login form using JSC n MySql

please send me full code for a simple login page using my jsc n mysql
[76 byte] By [ustaada] at [2007-11-26 19:18:15]
# 1

here i hav got code for a simple login form usin

JAVA and MySQl

public String button1_action() {

String Username = (String) this.textField1.getValue();

String pwd = (String) this.passwordField1.getValue();

boolean isValidUser=false;

com.sun.sql.rowset.CachedRowSetXImpl loginRowSet=new com.sun.sql.rowset.CachedRowSetXImpl();

try {

loginRowSet.setDataSourceName("java:comp/env/jdbc/sms");

loginRowSet.setCommand("SELECT * FROM login");

loginRowSet.setTableName("login");

loginRowSet.execute();

loginRowSet.beforeFirst();

while(loginRowSet.next()){

String Username1 = loginRowSet.getString("name");

String Password1 = loginRowSet.getString("password");

if(Username.equals(Username1) && pwd.equals(Password1)){

return "case1";

}

}

if (!isValidUser){

staticText1.setValue( " logon failed");

}

}

catch (Exception e) {

error("Login Failed : " + e.getMessage());

throw new FacesException(e);

} finally {

loginRowSet.close();

}

return null;

}

Make some changes in session bean also

****************************************************

protected ApplicationBean1 getApplicationBean1() {

return (ApplicationBean1)getBean("ApplicationBean1");

}

plz add this also

public boolean do_rand() {

boolean do_rand = true;

try{

loginRowSet.setCommand("SELECT * FROM login ");

}catch(SQLException ex) {

if(ex != null ){

ex.printStackTrace();

errorRand = "error do random";

do_rand = false;

}

return do_rand;

} catch(Exception e) {

e.printStackTrace();

return false;

}

return true;

}

ustaada at 2007-7-9 21:33:29 > top of Java-index,Development Tools,Java Tools...