📄 logindao.java
字号:
package zhxt.login.ejb;
/************************************************************
Copyright (C), 1988-1999, 易新科技有限公司.
FileName: UserDAO.JAVA
Author: Lotus Version : Date:
Description: // 数据源模块
Version: // 试验版
Function List: // 设置数据库字段
1. -------
History: // 历史修改记录
<author> <time> <version > <desc>
Lotus 04.3.4
***********************************************************/
import java.sql.*;
import javax.sql.*;
import java.util.*;
public class LoginDAO {
//数据库表格字段
private String account; //操作人员编码 对应Table :Sys02003 Col:Szgxx00
private String password;
//数据库连接对象
private Connection conn;
private String sql;
private PreparedStatement pstmt;
private ResultSet rs;
public String getAccount(){
return account;
}
public void setAccount(String account)
{
this.account = account;
}
//得到用户编码
public String getUserByAccount(String SGZXX00) throws SQLException
{
try
{
sql = "select * from zhxt.userinfo where username = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,SGZXX00);
rs = pstmt.executeQuery() ;
pstmt.close();
if (rs.next())
{
this.account = rs.getString(2);
rs.close();
return this.account;
}
else
{
return "";
}
}
catch(Exception e)
{
throw new SQLException("getUserByAccount: " + e.toString());
}
finally
{
try{if(pstmt!=null) pstmt.close();}
catch(Exception e){}
}
}
//得到用户密码
public String getPassByAccount(String Szgxx00) throws SQLException
{
try
{
sql = "select passwd from zhxt.userinfo where username = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1,Szgxx00);
rs = pstmt.executeQuery() ;
if (rs.next())
{
this.password = rs.getString(1);
return this.password;
}
else
{
return "";
}
}
catch(Exception e)
{
throw new SQLException("getPassByAccount: " + e.toString());
}
finally
{
try{if(pstmt!=null) pstmt.close();}
catch(Exception e){}
}
}
/**
* Method setConn.
* @param connection
*/
/**
* Returns the conn.
* @return Connection
*/
public Connection getConn() {
return conn;
}
/**
* Sets the conn.
* @param conn The conn to set
*/
public void setConn(Connection conn) {
this.conn = conn;
}
/**
* Returns the password.
* @return String
*/
public String getPassword() {
return password;
}
/**
* Sets the password.
* @param password The password to set
*/
public void setPassword(String password) {
this.password = password;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -