public User login(User lu){
User user = null;
JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDs());
try{
String sql = "select * from user where username=? and password=?";
user = template.queryForObject(sql, new BeanPropertyRowMapper<User>(User.class), lu.getUsername(), lu.getPassword());
}catch (Exception e){
System.out.println(e);
return user;
}
public class JDBCUtils {
private static DataSource ds;
static{
try {
Properties pro = new Properties();
pro.load(JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties"));
ds = new DruidDataSourceFactory().createDataSource(pro);