?? usersessionbean.java~25~
字號:
package ejb;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.naming.*;
import java.util.*;
/**
* 操作UserInfo表
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class UserSessionBean implements SessionBean {
SessionContext sessionContext;
public void ejbCreate() throws CreateException {
}
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
/**
* 檢測用戶名
* @param us String
* @param pw String
* @return boolean
*/
public boolean check(String us, String pw) {
boolean bool=false;
try{
Context ct = new InitialContext();
UserInfoHome home=(UserInfoHome)ct.lookup("UserInfo");
UserInfo rm = home.findByPrimaryKey(us);
if(rm.getUserCode().equals(us)&&rm.getUserPW().equals(pw))bool=true;
}catch(Exception e){e.printStackTrace();}
return bool;
}
/**
* 注冊用戶信息
* @param us String
* @param name String
* @param pw String
* @param shenfenzheng String
* @param telephone String
* @param address String
* @param youzhengbianma String
* @param email String
* @return boolean
*/
public boolean inster(String us, String name,String pw,String shenfenzheng,String telephone,
String address,String youzhengbianma,String email) {
boolean bool=false;
try{
Context ct = new InitialContext();
UserInfoHome home=(UserInfoHome)ct.lookup("UserInfo");
UserInfo rm = home.create(us);
rm.setUserName(name);
rm.setUserPW(pw);
rm.setShenfenzheng(shenfenzheng);
rm.setTelephone(telephone);
rm.setAddress(address);
rm.setYouZhengBianMa(youzhengbianma);
rm.setEmail(email);
bool=true;
}catch(Exception e){e.printStackTrace();}
return bool;
}
/**
* 刪除
* @param us String
* @return boolean
*/
public boolean delete(String us){
boolean bool=false;
try{
Context ct = new InitialContext();
UserInfoHome home=(UserInfoHome)ct.lookup("UserInfo");
UserInfo rm = home.findByPrimaryKey(us);
rm.remove();
bool=true;
}catch(Exception e){e.printStackTrace();}
return bool;
}
/**
* 修改
* @param us String
* @param name String
* @param pw String
* @param shenfenzheng String
* @param telephone String
* @param address String
* @param youzhengbianma String
* @param email String
* @return boolean
*/
public boolean xiugai(String us, String name,String pw,String shenfenzheng,String telephone,
String address,String youzhengbianma,String email){
boolean bool=false;
try{
Context ct = new InitialContext();
UserInfoHome home=(UserInfoHome)ct.lookup("UserInfo");
UserInfo rm = home.findByPrimaryKey(us);
rm.setUserName(name);
rm.setUserPW(pw);
rm.setShenfenzheng(shenfenzheng);
rm.setTelephone(telephone);
rm.setAddress(address);
rm.setYouZhengBianMa(youzhengbianma);
rm.setEmail(email);
bool=true;
}catch(Exception e){e.printStackTrace();}
return bool;
}
public boolean jiance(String us){
boolean bool=false;
try{
Context ct = new InitialContext();
UserInfoHome home = (UserInfoHome) ct.lookup("UserInfo");
UserInfo rm = home.findByPrimaryKey(us);
}catch(Exception e){bool=true;e.printStackTrace();}
return bool;
}
public List selectAllUser() {
ArrayList list=new ArrayList();
try{
Context ct = new InitialContext();
UserInfoHome home = (UserInfoHome) ct.lookup("UserInfo");
Iterator it=home.findAllUser().iterator();
while(it.hasNext()){
UserInfo userInfo=(UserInfo)it.next();
UserInfoVo vo = new UserInfoVo();
vo.setAddress(userInfo.getAddress());
vo.setEmail(userInfo.getEmail());
vo.setShenfenzheng(userInfo.getShenfenzheng());
vo.setTelephone(userInfo.getTelephone());
vo.setUserCode(userInfo.getUserCode());
vo.setUserName(userInfo.getUserName());
vo.setUserPW(userInfo.getUserPW());
vo.setYouZhengBianMa(userInfo.getYouZhengBianMa());
list.add(vo);
}
}catch(java.lang.Exception e){e.printStackTrace();}
return list;
}
public void untitledMethod1() {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -