📄 customerbobean.java~56~
字号:
package prj37_1;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import prj37_1.CustomerDto;
import javax.rmi.PortableRemoteObject;
import factory.EjbFactory;
public class CustomerBoBean
implements SessionBean {
SessionContext sessionContext;
CustomerDaoHome home;
CustomerDao remote;
public void ejbCreate() throws CreateException {
try {
Object obj = EjbFactory.getEjbHome("CustomerDao");
home = (CustomerDaoHome)PortableRemoteObject.narrow(obj,CustomerDaoHome.class);
remote = home.create();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
public CustomerDto login(String account, String password) {
try {
CustomerDto cus = remote.findCusByAccount(account);
if(cus!=null && cus.getPassword().equals(password)){
return cus;
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public boolean reg(String account, String password, String cname) {
try {
Object obj = EjbFactory.getEjbHome("CustomerDto");
CustomerDtoHome cusHome = (CustomerDtoHome)PortableRemoteObject.narrow(obj,CustomerDtoHome.class);
CustomerDto cus = cusHome.create();
cus.setAccount(account);
cus.setPassword(password);
cus.setCname(cname);
cus.setCbalance(0);
remote.insert(cus);
cus.remove();//腾出内存
return true;
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
public boolean cunkuan(CustomerDto cus) {
try {
remote.update(cus);
cus.remove();//腾出内存
return true;
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
public boolean qukuan(CustomerDto cus) {
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -