/**
*
*/
package doa;
import java.sql.*;
import dao.LoginBean;
/**
* @author Boomiraj
*
*/
public class UserDOA {
/**
*
*/
public UserDOA() {
// TODO Auto-generated constructor stub
}
static Connection con ;
static ResultSet rs ;
static Statement stmt ;
public static LoginBean login(LoginBean lb) {
//LoginBean lbean = new LoginBean();
//System.out.println("Test");
try {
Class.forName("com.mysql.jdbc.Driver");
try {
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin");
stmt = con.createStatement();
//lb.setUsername("Boomiraj");
//lb.setPassword("boomi@123");
String uname = lb.getUsername();
String pword = lb.getPassword();
System.out.println(uname);
System.out.println(pword);
rs = stmt.executeQuery("select * from login where UserName= '"+uname+"' and PASSWORD='"+pword+"' ");
boolean more = rs.next();
if(!more){
System.out.println(" Not Matched ");
}
if(more){
String fname = rs.getString("FirstName");
lb.setFirstname(fname);
String last = rs.getString("LastName");
lb.setLastname(last);
lb.setValid(true);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return lb;
}
}
*
*/
package doa;
import java.sql.*;
import dao.LoginBean;
/**
* @author Boomiraj
*
*/
public class UserDOA {
/**
*
*/
public UserDOA() {
// TODO Auto-generated constructor stub
}
static Connection con ;
static ResultSet rs ;
static Statement stmt ;
public static LoginBean login(LoginBean lb) {
//LoginBean lbean = new LoginBean();
//System.out.println("Test");
try {
Class.forName("com.mysql.jdbc.Driver");
try {
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin");
stmt = con.createStatement();
//lb.setUsername("Boomiraj");
//lb.setPassword("boomi@123");
String uname = lb.getUsername();
String pword = lb.getPassword();
System.out.println(uname);
System.out.println(pword);
rs = stmt.executeQuery("select * from login where UserName= '"+uname+"' and PASSWORD='"+pword+"' ");
boolean more = rs.next();
if(!more){
System.out.println(" Not Matched ");
}
if(more){
String fname = rs.getString("FirstName");
lb.setFirstname(fname);
String last = rs.getString("LastName");
lb.setLastname(last);
lb.setValid(true);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return lb;
}
}
No comments:
Post a Comment