LoginDaoImpl.java
package testlab.dao.impl;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.springframework.jdbc.core.JdbcTemplate;
import testlab.dao.LoginDao;
/**
*
* @author ravi
*/
public class LoginDaoImpl implements LoginDao,Serializable {
private JdbcTemplate jdbcTemplate;
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
@Override
public boolean validateLogin(String username, String password, String user_type) {
boolean check = false;
try {
System.out.println("in sdfssssssssssss::");
Connection con = jdbcTemplate.getDataSource().getConnection();
System.out.println("con::" + con);
String loginQuery = "select user_id,password,user_type from user_mstr where user_id=? and password=? and user_type=?";
PreparedStatement stmt = con.prepareStatement(loginQuery);
stmt.setString(1, username);
stmt.setString(2, password);
stmt.setString(3, user_type);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
if (rs.getString("user_id") != null && rs.getString("password") != null && rs.getString("user_type") != null) {
System.out.println("form dbname ::" + rs.getString("user_id"));
System.out.println("form dbpassword ::" + rs.getString("password"));
check = true;
}
}
//stmt.execute();
//String lastName = this.jdbcTemplate.queryForObject("select name from user_mstr where user_id = ?",new Object[]{1}, String.class);
// System.out.println("hi::"+lastName);
} catch (Exception ex) {
}
return check;
}
/**
* @param jdbcTemplate the jdbcTemplate to set
*/
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
}
package testlab.dao.impl;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.springframework.jdbc.core.JdbcTemplate;
import testlab.dao.LoginDao;
/**
*
* @author ravi
*/
public class LoginDaoImpl implements LoginDao,Serializable {
private JdbcTemplate jdbcTemplate;
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
@Override
public boolean validateLogin(String username, String password, String user_type) {
boolean check = false;
try {
System.out.println("in sdfssssssssssss::");
Connection con = jdbcTemplate.getDataSource().getConnection();
System.out.println("con::" + con);
String loginQuery = "select user_id,password,user_type from user_mstr where user_id=? and password=? and user_type=?";
PreparedStatement stmt = con.prepareStatement(loginQuery);
stmt.setString(1, username);
stmt.setString(2, password);
stmt.setString(3, user_type);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
if (rs.getString("user_id") != null && rs.getString("password") != null && rs.getString("user_type") != null) {
System.out.println("form dbname ::" + rs.getString("user_id"));
System.out.println("form dbpassword ::" + rs.getString("password"));
check = true;
}
}
//stmt.execute();
//String lastName = this.jdbcTemplate.queryForObject("select name from user_mstr where user_id = ?",new Object[]{1}, String.class);
// System.out.println("hi::"+lastName);
} catch (Exception ex) {
}
return check;
}
/**
* @param jdbcTemplate the jdbcTemplate to set
*/
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
}
No comments:
Post a Comment