⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userlogbean_p3hc9l__weblogic_cmp_rdbms.java

📁 一个使用java 写的进销存代码 使用了ejb 等技术 是学习j2ee的好
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    java.sql.PreparedStatement[] __WL_stmt_array = new java.sql.PreparedStatement[1];        java.sql.PreparedStatement __WL_stmt_userLog_0 = null;    __WL_stmt_array[0] = __WL_stmt_userLog_0;        
        String[] __WL_query_array = new String[1];    
    
        __WL_query_array[0] = "INSERT INTO userLog (id, programName, operationContent, userName, operationDate) VALUES (?, ?, ?, ?, ?)";    
    
    if(__WL_verbose) {
      for (int i = 0 ; i < 1 ; i++) {
        Debug.say("__WL_getBulkStmtArray() produced sqlString " + __WL_query_array[i]);
      }
    }
    
        __WL_stmt_array[0] = __WL_con.prepareStatement(__WL_query_array[0]);    
    
    return __WL_stmt_array;
    
  }
  
  public void __WL_setBeanParamsForCreateArray(java.sql.PreparedStatement[] __WL_stmt_array)
  throws Exception
  {
    
    // preparedStatementParamIndex reset.    if(!__WL_pm.setParamNull(__WL_stmt_array[0], 1, this.id, "id")) {      __WL_stmt_array[0].setInt(1, this.id.intValue());      if (__WL_verbose) {        Debug.say("paramIdx :"+1+" binded with value :"+this.id);      }    }        if(!__WL_pm.setParamNull(__WL_stmt_array[0], 2, this.programName, "programName")) {      __WL_stmt_array[0].setString(2, this.programName);      if (__WL_verbose) {        Debug.say("paramIdx :"+2+" binded with value :"+this.programName);      }    }        if(!__WL_pm.setParamNull(__WL_stmt_array[0], 3, this.operationContent, "operationContent")) {      __WL_stmt_array[0].setString(3, this.operationContent);      if (__WL_verbose) {        Debug.say("paramIdx :"+3+" binded with value :"+this.operationContent);      }    }        if(!__WL_pm.setParamNull(__WL_stmt_array[0], 4, this.userName, "userName")) {      __WL_stmt_array[0].setString(4, this.userName);      if (__WL_verbose) {        Debug.say("paramIdx :"+4+" binded with value :"+this.userName);      }    }        if(!__WL_pm.setParamNull(__WL_stmt_array[0], 5, this.operationDate, "operationDate")) {      __WL_stmt_array[0].setTimestamp(5, this.operationDate);      if (__WL_verbose) {        Debug.say("paramIdx :"+5+" binded with value :"+this.operationDate);      }    }    
    
  }
  
  public void __WL_resetIsModifiedVars() {
    for (int __WL_i = 0; __WL_i < __WL_isModified.length; __WL_i++) {
      __WL_isModified[__WL_i] = false;
    }
    __WL_modifiedBeanIsRegistered = false;
    
  }
  
  public boolean __WL_exists(Object __WL_key) {
    if (__WL_verbose) {
      Debug.say("exists: " + __WL_key);
    }
    
    java.sql.Connection __WL_con = null;
    java.sql.PreparedStatement __WL_stmt = null;
    java.sql.ResultSet __WL_rs = null;
    try {
      java.lang.Integer __WL_pk = (java.lang.Integer) __WL_key;
      __WL_con = __WL_pm.getConnection();
      
      java.lang.String __WL_query =
      "select id from userLog where id = ?";
      
      __WL_stmt = __WL_con.prepareStatement(__WL_query);
      
      // preparedStatementParamIndex reset.
            if(!__WL_pm.setParamNull(__WL_stmt, 1, __WL_pk, "id")) {        __WL_stmt.setInt(1, __WL_pk.intValue());        if (__WL_verbose) {          Debug.say("paramIdx :"+1+" binded with value :"+__WL_pk);        }      }      
      
      __WL_rs = __WL_stmt.executeQuery();
      if (__WL_rs.next()) {
        return true;
      }
      else {
        return false;
      }
    } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }
    
    finally {
      __WL_pm.releaseResources(__WL_con, __WL_stmt, __WL_rs);
    }
    
  }
  
  public void __WL_checkExistsOnMethod() throws NoSuchEntityException
  {
    
  }
  
  public short __WL_getBeanState() 
  {
    return __WL_bean_state;
  } 
  
  public void __WL_setBeanState(short value)
  {
    __WL_bean_state = value;
  }
  
  
  public String __WL_getM2NSQL(String cmrf,
  int    operation)
  {
    return "";
  }
  
  public void __WL_setBeanParamsForM2NStmt(PreparedStatement __WL_stmt,
  String            cmrf,
  int               operation)
  throws SQLException
  {
    
  }
  
  
  
  // end of CMPBean
  // ================================================================
  
  
  //=================================================================
  // implementation of javax.ejb.EntityBean
  
  public boolean __WL_beanIsLoaded() { 
    return __WL_beanIsLoaded; 
  }
  
  void pkCheck()
  throws javax.ejb.CreateException
  {
    // check that 'id' was set    if (!__WL_isModified[0]) {      throw new javax.ejb.CreateException("In EJB UserLog, primary key field 'id' was not set during ejbCreate.  All primary key fields must be initialized during ejbCreate.");    }
  }
  
  
  public java.lang.Integer ejbCreate(java.lang.Integer arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.sql.Timestamp arg4)
  throws javax.ejb.CreateException
  {
    int oldState = __WL_method_state;
    try {
      __WL_method_state = STATE_EJB_CREATE;
      
      for (int __WL_i = 0; __WL_i < 5; __WL_i++) {
        __WL_isLoaded[__WL_i] = true;
        __WL_isModified[__WL_i] = false;
      }
      
      __WL_beanIsLoaded = true;
      
      // set true, this prevents us from registering the bean until after the
      // database insert
      __WL_modifiedBeanIsRegistered = true;
      
      
      // initialize persistent and cached relationship variables, this
      // is done here purely to ensure robustness as the CMP variables
      // are also initialized whenever the bean enters the pooled state
            operationDate = null;      programName = null;      userName = null;      operationContent = null;      id = null;      
            
      
      super.ejbCreate( arg0, arg1, arg2, arg3, arg4);
      
            pkCheck();      
      
      
      
            java.lang.Integer __WL_pk = (java.lang.Integer) __WL_getPrimaryKey();      return __WL_pk;    } catch (javax.ejb.CreateException ce) {      throw ce;    } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }
    
    finally {
      __WL_method_state = oldState;
    }
  }
  
  
  public void ejbPostCreate(java.lang.Integer arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.sql.Timestamp arg4)
  throws javax.ejb.CreateException
  {
    int oldState = __WL_method_state;
    try {
      __WL_method_state = STATE_EJB_POSTCREATE;
      
      
      
      super.ejbPostCreate( arg0, arg1, arg2, arg3, arg4);
      
      __WL_create();      
      
      
      
    } catch (javax.ejb.CreateException ce) {      throw ce;      
      
    } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }
    
    finally {
      __WL_method_state = oldState;
    }
  }
  
  
    private Object __WL_create() throws Exception {
    if (__WL_verbose) {
      Debug.say("called __WL_create.");
    }
    
    java.sql.Connection __WL_con = null;
        java.sql.PreparedStatement[] __WL_stmt_array = new java.sql.PreparedStatement[1];        java.sql.PreparedStatement __WL_stmt_userLog_0 = null;    __WL_stmt_array[0] = __WL_stmt_userLog_0;        
        String[] __WL_query_array = new String[1];    
    
    
    
    java.lang.Integer __WL_pk = null;
    
    try {
      
            __WL_pk = this.id;      
      
      __WL_con = __WL_pm.getConnection();
      if(__WL_verbose) {
        Debug.say("__WL_create() got connection.");
      }
      
            __WL_query_array[0] = "INSERT INTO userLog (id, programName, operationContent, userName, operationDate) VALUES (?, ?, ?, ?, ?)";      
      
      if (__WL_verbose) {
        for (int i = 0 ; i < 1 ; i++) {
          Debug.say("__WL_create() produced sqlString " + __WL_query_array[i]);
        }
      }
      
            __WL_stmt_array[0] = __WL_con.prepareStatement(__WL_query_array[0]);      
      
      __WL_setBeanParamsForCreateArray(__WL_stmt_array);
      
      if(__WL_verbose) {
        Debug.say("__WL_create() about to execute sql.");
      }
      for (int i = 0 ; i < 1 ; i++) {
        if (__WL_stmt_array[i].executeUpdate() != 1) {
          throw new java.lang.Exception("Failed to CREATE Bean.  Primary Key Value: '" + __WL_pk + "'");
        }
      }
      
      
      
      for (int __WL_i = 0; __WL_i < __WL_isModified.length; __WL_i++) {
        __WL_isModified[__WL_i] = false;
      }
      __WL_modifiedBeanIsRegistered = false;
      
      return __WL_pk;
    } catch (java.sql.SQLException se) {
      //ejb wants a duplicate key exception if that was what happened
      if(__WL_verbose) {
        Debug.say("__WL_create() "+
        "checking for duplicate key " + __WL_pk);
      }
      boolean exists = false;
      try {
        exists = __WL_exists(__WL_pk);
      }
      catch (Exception e) {
        throw se;
      }
      if (exists) {
        throw new javax.ejb.DuplicateKeyException(
        "Bean with " +
        "primary key: '" + __WL_pk + "' already exists.");
      }
      else {
        throw se;
      }
      
    } finally {
      __WL_pm.releaseArrayResources(__WL_con, __WL_stmt_array, null);
    }
  }
  
  
  public void ejbRemove() throws javax.ejb.RemoveException {    java.sql.Connection __WL_con = null;
        java.sql.PreparedStatement[] __WL_stmt_array = new java.sql.PreparedStatement[1];        java.sql.PreparedStatement __WL_stmt_userLog_0 = null;    __WL_stmt_array[0] = __WL_stmt_userLog_0;        
        String[] __WL_query_array = new String[1];    
    
    java.sql.PreparedStatement __WL_stmt = null;
    
    int oldState = __WL_method_state;
    
    try {
      __WL_method_state = STATE_EJB_REMOVE;
      int __WL_num = 0;
      if (__WL_verbose) {
        Debug.say("ejbRemove " + __WL_ctx.getPrimaryKey());
      }
      super.ejbRemove();
      
      try {
        
        
        java.lang.Integer __WL_pk = (java.lang.Integer) __WL_ctx.getPrimaryKey();
        
        __WL_con = __WL_pm.getConnection();
        
        __WL_query_array[0] = "DELETE FROM userLog WHERE id = ?" ;        
        
                __WL_stmt_array[0] = __WL_con.prepareStateme

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -