customerdaobean.java~56~
来自「郭克华j2ee高级框架实战教学视频源代码 这个是比较值得一看的 由郭克华博士」· JAVA~56~ 代码 · 共 100 行
JAVA~56~
100 行
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");
PortableRemoteObject.narrow(obj,)
}
catch (Exception ex) {
ex.printStackTrace();
}
return cus;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?