⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userdaoimpl.java

📁 网络硬盘
💻 JAVA
字号:
package com.zte.webfile.dao;
import com.zte.webfile.dal.DataAdapter;
import com.zte.webfile.dto.UserDTO;
import com.zte.webfile.tool.Tool;

import java.util.*;
public class userDAOImpl implements userDAOInterface{
	   public int updatePwd(String password){
//			 用户返回信号,true为修改成功 ,false为修改失败,
		   int num=0;
		   String sql_updatePassword = new Tool().getProperties("updatePassword");
		   Vector arg=new Vector();
		   arg.add(password);
		   //接受返回值
		   try{
				int i = DataAdapter.update(sql_updatePassword,arg);
				if(i!=-1){
					num=1;	
				}
			   }catch(Exception e){
				   e.printStackTrace();
			   }
			   return num;
	   }
	   public int update(UserDTO ud){
//		 用户返回信号,true为修改成功 ,false为修改失败,
		   int num=0;
		   //用户ID
		   Integer userId=ud.getId();
		   //用户名
		   String userName=ud.getUserName();
		   //密码
		   String password=ud.getPassword();
		   //Email
		   String email=ud.getEmail();
	       //从配置文件中读取sql语句
		   String sql_updateInfo = new Tool().getProperties("updateInfo");
		   Vector arg=new Vector();
		   arg.add(password);
		   arg.add(email);
		   arg.add(userId);
//		 接受返回信息
		   try{
			int i = DataAdapter.update(sql_updateInfo,arg);
			if(i!=-1){
				num=1;	
			}
		   }catch(Exception e){
			   e.printStackTrace();
		   }
		   return num;
	   }
	   public HashMap finduser(String username){
			// 定义返回值
			Vector vt = new Vector();
			HashMap map=new HashMap();
			// 从配置文件中读取sql语句
			String sql_finduser = new Tool().getProperties("finduser");
			String file = new Tool().getProperties("userArray");
			String[] userArray=file.split(",");
			Vector arg = new Vector();
			arg.add(username);
//			 接受返回信息
			try {
				vt = DataAdapter.getData(sql_finduser, arg);	
				if(vt==null){
					return map;
				}else{
//					for(int j=0;j<vt.size();j++){
//						Vector row = (Vector) vt.get(j);
//						int ID= Integer.valueOf(row.get(0).toString());
//						map.put((userArray[0]+j).trim(),ID);
//						for(int c=1;c<userArray.length;c++){
//						 String path=String.valueOf(row.get(c).toString());
//						 map.put((userArray[c]+j).trim(),path.trim());
//						}
//					}
					Vector row = (Vector) vt.get(0);
					int ID= Integer.valueOf(row.get(0).toString());     			
	     			String uname=String.valueOf(row.get(1).toString());
	     			String userpwd=String.valueOf(row.get(2).toString());
	     			String email=String.valueOf(row.get(3).toString());
	     			map.put("id",ID);
	     			map.put("username", uname);
	     			map.put("userpwd", userpwd);
	     			map.put("email", email);
				}			
				
			} catch (Exception e) {
				e.printStackTrace();
			}
			return map;
	   }
	   public int findusername(String username){
	       //定义返回值
			Vector vt = new Vector();
		    int i=0;
//		  从配置文件中读取sql语句
			String sql_findusername = new Tool().getProperties("findusername");
			Vector arg = new Vector();
			arg.add(username);
			try {
				vt = DataAdapter.getData(sql_findusername, arg);	
				if(vt==null){
					i=1;
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		   return i;
	   }
	   public int findpassword(String username){
//		 定义返回值
			Vector vt = new Vector();
		    int i=0;
//		  从配置文件中读取sql语句
			String sql_findpwd = new Tool().getProperties("findpwd");
			Vector arg = new Vector();
			arg.add(username);
			try {
				vt = DataAdapter.getData(sql_findpwd, arg);	
				if(vt==null){
					i=1;
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		   return i;
	   }
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -