开始设计一个系统,首页没有登陆界面,只有管理员在管理界面登陆后直接跳转后到管理界面,原来管理员有一个表,现在重新建一个普通人员登陆表,怎样改写如下的登陆JAVABEAN可以实现,设计后的登陆界面是有选择的,如果是选择管理员就登陆到管理界面,如果是普通人员登陆就转到首页。
/*
* Created on 2004-9-20
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package util;
import news.sql_data;
import news.strFormat;
import java.sql.*;
/**
* Title: 用户登录信息检查
* Description:
* Copyright: Copyright (c) 2004
* @author: ning
* @version 1.0
*/
public class login {
private String username; //登录用户名
private String passwd; //登录密码
private long userid=0; //用户ID号
private String authority; //用户权限
String sqlStr; //检索数据库SQL语句
sql_data sqlbean=new sql_data();
public static void main (String [] args) {}
public login() throws Exception{
username = " ";
passwd = " ";
}
public String getUsername() {
return username;
}
public void setUsername(String newusername) {
username = newusername;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String newpasswd) {
passwd = newpasswd;
}
public long getUserid() {
return userid;
}
public String getAuthority() {
return authority;
}
public void setUserid (long uid) {
userid = uid;
}
public String getSql() {
sqlStr = "select * from admin where adminuser = ' " + strFormat.toSql(username) + " ' and adminpass = ' " + strFormat.toSql(passwd) + " ' ";
return sqlStr;
}
public boolean excute() throws Exception {
boolean flag = false;
ResultSet rs = sqlbean.executeQuery(getSql());
if (rs.next()){
userid = rs.getLong( "id ");
authority=rs.getString( "authority ");
flag = true;
}
rs.close();
sqlbean.closeConn();
return flag;
}
public void setinfo(String lastip,String username) throws Exception {
sqlbean.executeUpdate( "UPDATE admin SET lasttime = getdate(),lastip= ' "+lastip+ " ' where adminuser= ' "+username+ " ' ");
sqlbean.closeConn();
}
}