📄 logindaoimpl.java
字号:
package com.zte.webfile.dao;
import java.util.Vector;
import com.zte.webfile.conf.Config;
import com.zte.webfile.dal.DataAdapter;
import com.zte.webfile.dto.UserDTO;
import com.zte.webfile.tool.Tool;
import org.apache.log4j.Logger;
public class loginDAOImpl implements loginDAOInterface{
/**
* 登陆时调用
*
* @param username,password
* 用户名,密码
* @return 登陆成功或者失败信号
* @throws Exception
*/
final Logger log=Logger.getLogger(loginDAOImpl.class);
public boolean login(String username,String password){
// 用户返回信号,true为登陆成功 ,false为登陆失败,
boolean bl=false;
//从配置文件中读取sql语句
String sql_login = new Tool().getProperties("login");
//SQL从用户表中查询是否有此用户
Vector arg=new Vector();
arg.add(username);
arg.add(password);
// 接受返回信息
// String sql_login="select * from f_user where username=? and userpwd=?";
// PreparedStatement ps = null;
// System.out.println(""+sql_login);
try{
// Class.forName("oracle.jdbc.driver.OracleDriver");
// String url="jdbc:oracle:thin:@192.168.1.33:1521:webfile";
// String user="zte";
// String password1="zte";
// Connection conn=DriverManager.getConnection(url,user,password1);
// ps=conn.prepareStatement(sql_login);
// ps.setString(1, username);
// ps.setString(2, password);
// bl = ps.execute();
Vector vector = DataAdapter.getData(sql_login,arg);
//如果用户表中有记录则返回真
if(vector!=null){
bl=true;
}
}catch(Exception e){
e.printStackTrace();
}
return bl;
}
/**
* 注册时调用
*
* @param userDTO
* 注册信息
* @return 登陆成功或者失败信号
* @throws Exception
*/
public int regit(UserDTO ud){
//用户返回信号,true为注册成功 ,false为注册失败,
int num=0;
//用户名
String userName=ud.getUserName();
//密码
String password=ud.getPassword();
//Email
String email=ud.getEmail();
//从配置文件中读取sql语句
String sql_insert = new Tool().getProperties("insert");
String sql_fileregit=new Tool().getProperties("fileinsert");
//获得用户ID
Tool tl=new Tool();
// String s=String.valueOf(tl.getUserID());
// Integer id=Integer.valueOf(s);
int id=tl.getUserID();
log.info("UserNameInfo"+userName+"IDInfor="+id+"//"+password+"//"+email);
Vector arg=new Vector();
arg.add(Integer.valueOf(id));
arg.add(userName);
arg.add(password);
arg.add(email);
int fileid=tl.getFileCount();
Vector arg1=new Vector();
arg1.add(fileid);
arg1.add(userName);
arg1.add("c:/upload/"+userName);
arg1.add("folder");
arg1.add(Integer.valueOf(0));
arg1.add("0");
arg1.add(userName);
arg1.add("1");
arg1.add(Integer.valueOf(0));
// 接受返回信息
try{
int i = DataAdapter.update(sql_insert,arg);
if(i!=-1){
num=1;
int j = DataAdapter.update(sql_fileregit,arg1);
if(j!=-1){
num=2;
}
}
}catch(Exception e){
e.printStackTrace();
}
return num;
}
/**
* 删除用户表中用户信息
*/
public boolean delete(){
boolean bl=false;
Tool tool=new Tool();
int id=(tool).getID();
String sql_delete = new Tool().getProperties("deleteuser");
Vector arg=new Vector();
arg.add(id);
try{
int i = DataAdapter.update(sql_delete,arg);
if(i!=-1){
bl=true;
}
}catch(Exception e){
e.printStackTrace();
}
return bl;
}
/**
* 退出时调用
*/
public void exit(){
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -