login.java
来自「一个很有用的电子刊物发布系统」· Java 代码 · 共 110 行
JAVA
110 行
package com.am;
import java.util.*;
import java.sql.*;
import java.text.*;
public class login extends user
{
private String strSql;
private Connection dbConn;
private int errNum;
private String errDesc;
SimpleDateFormat dateFormatter;
public login()
{
super();
strSql="";
errNum=0;
errDesc="";
}
public boolean isValidUser()
{
strSql="select * from `users` ";
strSql=strSql + " where userName='" + userName + "'";
strSql=strSql + " and userPassword='"+ userPassword + "'";
strSql=strSql + " and systemRole= '"+systemRole+"'";
Statement stmt=null;
ResultSet rs=null;
try
{
stmt=dbConn.createStatement();
rs =stmt.executeQuery(strSql);
if (rs.next())
{
ID=rs.getLong("ID");
userName=rs.getString("userName");
userPassword=rs.getString("userPassword");
name=rs.getString("name");
company=rs.getString("company");
depart=rs.getString("depart");
email=rs.getString("email");
myfields=rs.getString("myfields");
systemRole=rs.getString("systemRole");
createDatetime=rs.getString("createDatetime");
tag=rs.getInt("tag");
this.errNum=0;
this.errDesc="";
return true;
}
else
{
this.errNum=-1;
this.errDesc="Not Valid User";
return false;
}
}
catch(Exception ex)
{
this.errNum=-1;
this.errDesc=ex.toString();
return false;
}
finally
{
}
}
public void setConnection(Connection dbConn)
{
this.dbConn=dbConn;
}
private void exeSql(String strSql)
{
try
{
Statement stmt=dbConn.createStatement();
stmt.executeUpdate(strSql);
this.errNum=0;
this.errDesc="";
}
catch(Exception ex)
{
this.errNum=-1;
this.errDesc=ex.toString();
}
}
public int getErrNum()
{
return errNum;
}
public String getErrDesc()
{
return errDesc;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?