identify.java
来自「一个学籍管理系统。」· Java 代码 · 共 69 行
JAVA
69 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?