📄 acessbean.java
字号:
/*
* Created on 2005-5-12
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ddllogin.model;
import java.sql.*;
import zhangchunliang.model.AppMode;
//import java.util.Date;
//import java.text.DateFormat;
import kangyi.ConnectionPool.DbConnection;
/**
* @author duzhibo@neusoft
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class AcessBean {
DbConnection db = null;
Connection con = null;
//定义一个acessBean方法,返回值为int型,1为登陆成功,0为失败
public int acess(String userName) {
AppMode.registerUser();
Statement sql = null;
ResultSet rs = null;
//连接数据库的语句
String s1 = "select*from stuff where sid=" + "'" + userName + "'";
//System.out.println(s1 + "s1");
//连接数据库,判断用户名是不是存在
try {
db = new DbConnection();
con = db.getCon();
sql = con.createStatement();
rs = sql.executeQuery(s1);
if (rs.next()) {
con.close();
AppMode.loginoutUser();
return 1;
} else {
con.close();
AppMode.loginoutUser();
return 0;
}
} catch (Exception e) {
AppMode.loginoutUser();
System.out.println(e.getMessage() + "hahaha");
return 2;
}
}
public int acessp(String userName, String password) {
AppMode.registerUser();
Statement sql = null;
ResultSet rs = null;
String s2 = "select*from stuff where sid=" + "'" + userName + "'";
//System.out.println(s2);
try {
db = new DbConnection();
con = db.getCon();
sql = con.createStatement();
rs = sql.executeQuery(s2);
//System.out.println(password);
rs.first();
if ((password.equals(rs.getString(3))) && (rs.getInt(7) == 1)) {
con.close();
AppMode.loginoutUser();
return 1;
} else {
con.close();
AppMode.loginoutUser();
return 0;
}
} catch (Exception e) {
AppMode.loginoutUser();
System.out.println(e);
return 2;
}
}
public int upDate(String userName) {
AppMode.registerUser();
Statement sql = null;
ResultSet rs = null;
String s3 = "update stuff set stopflag=" + "'" + 0 + "'" + "where sid="
+ userName;
//System.out.println(s3);
try {
db = new DbConnection();
con = db.getCon();
sql = con.createStatement();
sql.executeUpdate(s3);
con.close();
AppMode.loginoutUser();
return 1;
} catch (Exception e) {
AppMode.loginoutUser();
System.out.println(e);
return 0;
}
}
public int judgeAccount(String userName){
AppMode.registerUser();
Statement sql = null;
ResultSet rs = null;
String s4 = "select*from stuff where sid=" + "'" + userName + "'";
try {
db = new DbConnection();
con = db.getCon();
sql = con.createStatement();
rs = sql.executeQuery(s4);
//System.out.println(password);
rs.first();
if (rs.getInt(7) == 1) {
con.close();
return 1;
} else {
con.close();
return 0;
}
} catch (Exception e) {
System.out.println(e);
return 2;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -