📄 hellobusiness.java
字号:
/*
* Created on 2007-4-16
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package hello.Business;
import hello.ConnDbo;
import hello.Bean.Address;
import hello.Form.HelloForm;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* @author we
*
* 业务处理类
* Window - Preferences - Java - Code Style - Code Templates
*/
public class HelloBusiness {
// 身份验证,验证成功返回1,否则返回0
public static int validateLogin(ConnDbo dbo,HelloForm frm){
Connection conn = null;
int tag = 0;//设置返回值,默认为0,代表验证不成功
// 设置数据库查询语句
StringBuffer sql = new StringBuffer();
sql.append("select username");
sql.append(" ,password");
sql.append(" from LoginUser");
sql.append(" where username=?");
sql.append(" and password=?");
// sql.append(" select username"); //1 账户
// sql.append(" ,password"); //2 密码
// sql.append(" from");
// sql.append(" User");
// sql.append(" where username =?");
// sql.append(" and password =?");
PreparedStatement stmt = null;
ResultSet rs = null;
try{
conn = dbo.getDatabaseConnectionTraditionally();
stmt = conn.prepareStatement(sql.toString());
stmt.setString(1,frm.getUserName());//系统管理员账户
stmt.setString(2,frm.getPassword());//系统管理员密码
rs = stmt.executeQuery();
if(rs.next()){
frm.setUserName(rs.getString(1));
tag=1;//验证成功标记
}
rs.close();
stmt.close();
}
catch(Exception e){
e.printStackTrace();
}
return tag;//返回验证标记
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -