?? huserbasicinfoenttestclient2.java
字號:
package clientejb;import javax.naming.*;import java.util.Properties;import javax.rmi.PortableRemoteObject;import java.util.Collection;public class hUserBasicInfoEntTestClient2 extends Object { private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first."; private static final int MAX_OUTPUT_LINE_LENGTH = 100; private boolean logging = true; private hUserBasicInfoEntRemoteHome hUserBasicInfoEntRemoteHomeObject = null; private hUserBasicInfoEntRemote hUserBasicInfoEntRemoteObject = null; //Construct the EJB test client public hUserBasicInfoEntTestClient2() { initialize(); } public void initialize() { long startTime = 0; if (logging) { log("Initializing bean access."); startTime = System.currentTimeMillis(); } try { //get naming context Context context = getInitialContext(); //look up jndi name Object ref = context.lookup("hUserBasicInfoEntRemote"); //look up jndi name and cast to Home interface hUserBasicInfoEntRemoteHomeObject = (hUserBasicInfoEntRemoteHome) PortableRemoteObject.narrow(ref, hUserBasicInfoEntRemoteHome.class); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded initializing bean access through Home interface."); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed initializing bean access."); } e.printStackTrace(); } } private Context getInitialContext() throws Exception { String url = "t3://j-af3d73a001034:7001"; String user = null; String password = null; Properties properties = null; try { properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); properties.put(Context.PROVIDER_URL, url); if (user != null) { properties.put(Context.SECURITY_PRINCIPAL, user); properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password); } return new InitialContext(properties); } catch(Exception e) { log("Unable to connect to WebLogic server at " + url); log("Please make sure that the server is running."); throw e; } } //---------------------------------------------------------------------------- // Methods that use Home interface methods to generate a Remote interface reference //---------------------------------------------------------------------------- public hUserBasicInfoEntRemote create(String h_user_id, String h_user_name, String h_user_id_card, String h_user_hos_id, String h_user_hos_dep, String h_user_phone, String h_user_email, String h_user_image, String h_user_remark) { long startTime = 0; if (logging) { log("Calling create(" + h_user_id + ", " + h_user_name + ", " + h_user_id_card + ", " + h_user_hos_id + ", " + h_user_hos_dep + ", " + h_user_phone + ", " + h_user_email + ", " + h_user_image + ", " + h_user_remark + ")"); startTime = System.currentTimeMillis(); } try { hUserBasicInfoEntRemoteObject = hUserBasicInfoEntRemoteHomeObject.create(h_user_id, h_user_name, h_user_id_card, h_user_hos_id, h_user_hos_dep, h_user_phone, h_user_email, h_user_image, h_user_remark); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: create(" + h_user_id + ", " + h_user_name + ", " + h_user_id_card + ", " + h_user_hos_id + ", " + h_user_hos_dep + ", " + h_user_phone + ", " + h_user_email + ", " + h_user_image + ", " + h_user_remark + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: create(" + h_user_id + ", " + h_user_name + ", " + h_user_id_card + ", " + h_user_hos_id + ", " + h_user_hos_dep + ", " + h_user_phone + ", " + h_user_email + ", " + h_user_image + ", " + h_user_remark + ")"); } e.printStackTrace(); } if (logging) { log("Return value from create(" + h_user_id + ", " + h_user_name + ", " + h_user_id_card + ", " + h_user_hos_id + ", " + h_user_hos_dep + ", " + h_user_phone + ", " + h_user_email + ", " + h_user_image + ", " + h_user_remark + "): " + hUserBasicInfoEntRemoteObject + "."); } return hUserBasicInfoEntRemoteObject; } public Collection findByName(String name) { Collection returnValue = null; long startTime = 0; if (logging) { log("Calling findByName(" + name + ")"); startTime = System.currentTimeMillis(); } try { returnValue = hUserBasicInfoEntRemoteHomeObject.findByName(name); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: findByName(" + name + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: findByName(" + name + ")"); } e.printStackTrace(); } if (logging) { log("Return value from findByName(" + name + "): " + returnValue + "."); } return returnValue; } public hUserBasicInfoEntRemote findByPrimaryKey(hUserBasicInfoEntPK pk) { long startTime = 0; if (logging) { log("Calling findByPrimaryKey(" + pk + ")"); startTime = System.currentTimeMillis(); } try { hUserBasicInfoEntRemoteObject = hUserBasicInfoEntRemoteHomeObject.findByPrimaryKey(pk); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: findByPrimaryKey(" + pk + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: findByPrimaryKey(" + pk + ")"); } e.printStackTrace(); } if (logging) { log("Return value from findByPrimaryKey(" + pk + "): " + hUserBasicInfoEntRemoteObject + "."); } return hUserBasicInfoEntRemoteObject; } //---------------------------------------------------------------------------- // Methods that use Remote interface methods to access data through the bean //---------------------------------------------------------------------------- public void setH_user_id(String h_user_id) { if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in setH_user_id(): " + ERROR_NULL_REMOTE); return ; } long startTime = 0; if (logging) { log("Calling setH_user_id(" + h_user_id + ")"); startTime = System.currentTimeMillis(); } try { hUserBasicInfoEntRemoteObject.setH_user_id(h_user_id); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: setH_user_id(" + h_user_id + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: setH_user_id(" + h_user_id + ")"); } e.printStackTrace(); } } public String getH_user_id() { String returnValue = ""; if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in getH_user_id(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getH_user_id()"); startTime = System.currentTimeMillis(); } try { returnValue = hUserBasicInfoEntRemoteObject.getH_user_id(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getH_user_id()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getH_user_id()"); } e.printStackTrace(); } if (logging) { log("Return value from getH_user_id(): " + returnValue + "."); } return returnValue; } public void setH_user_name(String h_user_name) { if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in setH_user_name(): " + ERROR_NULL_REMOTE); return ; } long startTime = 0; if (logging) { log("Calling setH_user_name(" + h_user_name + ")"); startTime = System.currentTimeMillis(); } try { hUserBasicInfoEntRemoteObject.setH_user_name(h_user_name); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: setH_user_name(" + h_user_name + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: setH_user_name(" + h_user_name + ")"); } e.printStackTrace(); } } public String getH_user_name() { String returnValue = ""; if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in getH_user_name(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getH_user_name()"); startTime = System.currentTimeMillis(); } try { returnValue = hUserBasicInfoEntRemoteObject.getH_user_name(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getH_user_name()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getH_user_name()"); } e.printStackTrace(); } if (logging) { log("Return value from getH_user_name(): " + returnValue + "."); } return returnValue; } public void setH_user_id_card(String h_user_id_card) { if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in setH_user_id_card(): " + ERROR_NULL_REMOTE); return ; } long startTime = 0; if (logging) { log("Calling setH_user_id_card(" + h_user_id_card + ")"); startTime = System.currentTimeMillis(); } try { hUserBasicInfoEntRemoteObject.setH_user_id_card(h_user_id_card); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: setH_user_id_card(" + h_user_id_card + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: setH_user_id_card(" + h_user_id_card + ")"); } e.printStackTrace(); } } public String getH_user_id_card() { String returnValue = ""; if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in getH_user_id_card(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getH_user_id_card()"); startTime = System.currentTimeMillis(); } try { returnValue = hUserBasicInfoEntRemoteObject.getH_user_id_card(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getH_user_id_card()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getH_user_id_card()"); } e.printStackTrace(); } if (logging) { log("Return value from getH_user_id_card(): " + returnValue + "."); } return returnValue; } public void setH_user_hos_id(String h_user_hos_id) { if (hUserBasicInfoEntRemoteObject == null) { System.out.println("Error in setH_user_hos_id(): " + ERROR_NULL_REMOTE); return ; } long startTime = 0; if (logging) { log("Calling setH_user_hos_id(" + h_user_hos_id + ")"); startTime = System.currentTimeMillis(); } try { hUserBasicInfoEntRemoteObject.setH_user_hos_id(h_user_hos_id); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: setH_user_hos_id(" + h_user_hos_id + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: setH_user_hos_id(" + h_user_hos_id + ")");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -