可以,
比如jsp里写:
bbsuser.login(uname,upass,request);
javabean里写:
public int login(String username, String userpassmd5,
HttpServletRequest request) { //论坛登陆
this.strDBURL = "jdbc
dbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" +
request.getRealPath("/") + "WEB-INF//mybbs.mdb";
try {
com.mypackage.mybbs.dbbean db = new com.mypackage.mybbs.dbbean(this.
strJDBCDriverName, this.strDBURL, "", "");
db.connect();
db.setStrSQL("select * from bbsuser where username=/'" + username +
"/' and userpass=/'" + userpass + "/'");
//");
//
db.excuteQuery();
this.setSqlRst(db.getSqlRst());
if (this.sqlRst != null) {
if (sqlRst.next()) {
System.out.println("你的用户名字是:/t" + sqlRst.getString("username"));
System.out.println("你的密码是:/t" + sqlRst.getString("userpass"));
System.out.println("一共有" + sqlRst.getRow() + "条记录<br>");
this.username = username;
this.userpass = userpass;
this.userVerify = "true";
return 1;
//1表示登陆成功
}
catch (SQLException ex) {
return 0;
//表示登陆失败
}
}