📄 customerdaobean.java~57~
字号:
package prj37_1;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.rmi.PortableRemoteObject;
import factory.EjbFactory;
public class CustomerDaoBean
implements SessionBean {
SessionContext sessionContext;
TCustomerRemoteHome home;
TCustomerRemote remote;
public void setSessionContext(SessionContext sessionContext) {
Object obj = EjbFactory.getEjbHome("TCustomerRemote");
home = (TCustomerRemoteHome)PortableRemoteObject.narrow(obj,TCustomerRemoteHome.class);
this.sessionContext = sessionContext;
}
public void ejbCreate() throws CreateException {
}
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public boolean insert(CustomerDto cus) {
try {
String account = cus.getAccount();
String password = cus.getPassword();
String cname = cus.getCname();
double cbalance = cus.getCbalance();
remote = home.create(account);
remote.setPassword(password);
remote.setCname(cname);
remote.setCbalance(new Float(cbalance));
return true;
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
public boolean update(CustomerDto cus) {
try {
String account = cus.getAccount();
String password = cus.getPassword();
String cname = cus.getCname();
double cbalance = cus.getCbalance();
remote = home.findByPrimaryKey(account);
remote.setPassword(password);
remote.setCname(cname);
remote.setCbalance(new Float(cbalance));
return true;
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
public boolean delete(CustomerDto cus) {
try {
String account = cus.getAccount();
remote = home.findByPrimaryKey(account);
remote.remove();
return true;
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
public CustomerDto findCusByAccount(String account) {
CustomerDto cus = null;
try {
remote = home.findByPrimaryKey(account);
Object obj = EjbFactory.getEjbHome("CustomerDto");
CustomerDtoHome cusHome = (CustomerDtoHome)PortableRemoteObject.narrow(obj,)
}
catch (Exception ex) {
ex.printStackTrace();
}
return cus;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -