📄 bankbmpclient.java
字号:
package bankbmp;
import bmp.BaseClient;
import javax.ejb.DuplicateKeyException;
import javax.naming.NamingException;
import java.rmi.RemoteException;
public final class BankBMPClient extends BaseClient {
private BankHome BankHome;
public BankBMPClient(String [] argv) throws NamingException
{
super(argv);
try {
BankHome = (BankHome)
narrow(getInitialContext().lookup("theBankEJB"), BankHome.class);
} catch (NamingException ne) {
System.err.println("Unable to lookup EJB: BankEJB");
System.err.println("Please make sure that you have deployed this EJB.");
throw ne;
}
}
private void runExample() throws Exception
{
Bank s = null;
try {
s = BankHome.create(1001,"ALi Han", 885, 2);
System.err.println("Created a ALi Han Bank BMP Entity.");
} catch (DuplicateKeyException dke) {
System.err.println("Bank named ALi Han already exists.");
System.err.println("Remove the ALi Han bean from your "+
"database table and re-run the example.");
throw dke;
} catch (Exception e) {
System.err.println("Unable to create Bank bean.");
System.err.println("Did you create the database tables?");
throw e;
}
try {
s.setaccountLevel(3);
System.err.println("Changed Bank's level to 3.");
} catch (RemoteException re) {
System.err.println("Unable to update Bank's level.");
re.printStackTrace();
throw re;
}
/*try {
s.remove();
System.err.println("Remove Bank's level to 3.");
} catch (Exception e) {
System.err.println("Unable to remove Bank bean.");
e.printStackTrace();
throw e;
}*/
}
public static void main(String[] argv) throws Exception
{
System.err.println("");
System.err.println("Running BankBMPClient.....");
System.err.println("");
BankBMPClient sc = new BankBMPClient(argv);
sc.runExample();
System.err.println("");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -