📄 identify.java
字号:
/*
* Created on 2004-5-25
*/
/**
* @author Administrator
* @Use For Indentify user's information
*/
import java.sql.*;
public class Identify
{
private String _userPassword;
private String _userNumber;
//User's type:0 for ordinary people,1 for student
//2 for techer,3 for administarator
private int _type;
private String _sql;
private Access myaccess;
public Identify(){}
public Identify(int type,String userNumber,String userPassword)
{
_type=type;
_userPassword=userPassword;
_userNumber=userNumber;
myaccess=Access.getAccess();
}
public boolean check()
{
ResultSet rs=null;
switch(_type)
{
case 1:_sql="SELECT studentID FROM student WHERE studentNumber='"+_userNumber+"' and studentPassword='"+_userPassword+"'";
break;
case 2:_sql="SELECT teacherID FROM teacher WHERE teacherName='"+_userNumber+"' and teacherPassword='"+_userPassword+"'";
break;
case 3:_sql="SELECT adminID FROM admin WHERE adminName='"+_userNumber+"' and adminPassword='"+_userPassword+"'";
break;
default:return false;
}
try
{
rs=myaccess.execQuery(_sql);
if(rs.next())
return true;
else
return false;
}catch(Exception ex)
{
System.out.println(ex);
}
finally
{
myaccess.closeConnection();
}
return false;
}
public static void main(String[] args)
{
Identify myidentify=new Identify(3,"admin","admin");
System.out.println(myidentify.check());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -