test.java
来自「ejb学习资料」· Java 代码 · 共 36 行
JAVA
36 行
package test;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import service.CustomerMgmtBeanRemote;
import entity.Customer;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Context ctx = new InitialContext();
CustomerMgmtBeanRemote cmbr =
(CustomerMgmtBeanRemote) ctx.lookup("CustomerMgmtBean3/remote");
Customer c = new Customer();
c.setName("c1");
c.setCity("bj");
c.setStreet("ca");
cmbr.save(c);
Customer c2 = cmbr.find("c1");
System.out.println(c2.getCity());
} catch (NamingException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?