Package org.fto.jthink.exception

Examples of org.fto.jthink.exception.JThinkRuntimeException


   */
  public EJBContainerTransaction(ResourceManager resManager, Element dataSourceConfig, Element trsctnConfig){
    super(resManager, dataSourceConfig, trsctnConfig);
    sessionCtx = (SessionContext)resManager.getResource(SessionContext.class.getName());
    if(sessionCtx==null){
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_SYS_RUNTIME, "javax.ejb.SessionContext没有找到, " +
              "请将SessionContext以SessionContext.class.getName()返回的值作为主键加入到资源管理器(ResourceManager)中.");
    }

  }
View Full Code Here


    recursionFlag--;
    if (recursionFlag > 0) {
      return;
    }
    else if (recursionFlag < 0) {
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_SYS_RUNTIME,
                  "事务嵌套标志小于了0. begin()与close()方法不匹配!");
    }
   
    try{
      Iterator keysIT = openedConnsHM.keySet().iterator();
      while(keysIT.hasNext()){
        String connId = (String)keysIT.next();
        Connection conn = (Connection)openedConnsHM.get(connId);
        /* 如果采用了连接池管理连接 */
        if(useConnectionPool(connId)){
          ConnectionPool connPool = ConnectionPool.getConnectionPool(connId);
          /* 将活动连接返回到连接池 */
          connPool.returnConnection(conn);
        }else{
          /* 释放连接 */
          conn.close();
        }
      }
    }catch(JThinkRuntimeException e){
      throw e;
    }catch(Exception e){
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_DB_SQL_EXCEPTION, "事务关闭时发生异常!", e);
    }finally{   
      openedConnsHM.clear();
    }
  }
View Full Code Here

      while (rs.next()) {
        rses.add(createDataObject(rs, doClazz));
      }
    }
    catch (SQLException ex) {
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_DB_EXEC_SQL_EXCEPTION, ex);
    }
    return rses;
  }
View Full Code Here

          rses.add(createDataObject(rs, doClazz));
        }
      }
    }
    catch (SQLException ex) {
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_DB_EXEC_SQL_EXCEPTION, ex);
    }
    return rses;
  }
View Full Code Here

      else {
        return DriverManager.getConnection(url, user, password);
      }
    }
    catch (Exception ex) {
      throw new JThinkRuntimeException(
          JThinkErrorCode.ERRCODE_DB_CANNOT_GET_CONNECTION,
          "Cannot get connection!  URL = " + url, ex);
    }
  }
View Full Code Here

  /**
   * 设置事务超时时间,单位:秒
   */
  public void setTransactionTimeout(int seconds){
    if(seconds<0){
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_SYS_RUNTIME, "不被支持的值,只允许大于等于0的值!");
    }
    this.timeout = seconds;
    if(ut!=null && seconds!=-1){
      try {
        ut.setTransactionTimeout(seconds);
      } catch (SystemException e) {
        throw new JThinkRuntimeException(
            JThinkErrorCode.ERRCODE_SYS_RUNTIME,
            "设置事务超时时间!", e);
      }
    }
  } 
View Full Code Here

          }
          ut.begin();
      }

    } catch (Exception e) {
      throw new JThinkRuntimeException(
          JThinkErrorCode.ERRCODE_SYS_BEGIN_TRANSACTION_FAILURE,
          "Not begin transaction!", e);
    } finally {
      if (ctx != null) {
        try {
          ctx.close();
        } catch (NamingException ne) {
          throw new JThinkRuntimeException(
              JThinkErrorCode.ERRCODE_SYS_BEGIN_TRANSACTION_FAILURE,
              "关闭Context对象失败!", ne);
        }
      }
    }
View Full Code Here

      if(ut!=null){
        ut.commit();
        ut = null;
      }
    } catch (Exception e) {
        throw new JThinkRuntimeException(
            JThinkErrorCode.ERRCODE_SYS_COMMIT_TRANSACTION_FAILURE,
            "Commit transaction failure", e);
    }
  }
View Full Code Here

      if(ut!=null){
        ut.rollback();
        ut = null;
      }
    } catch (Exception e) {
        throw new JThinkRuntimeException(
            JThinkErrorCode.ERRCODE_SYS_ROLLBACK_TRANSACTION_FAILURE,
            "Rollback transaction failure", e);
    }
  }
View Full Code Here

    recursionFlag--;
    if (recursionFlag > 0) {
      return;
    }
    else if (recursionFlag < 0) {
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_SYS_RUNTIME,
                  "事务嵌套标志小于了0. begin(),close()方法不匹配!");
    }
   
    try{
      if(ut!=null){
        ut.rollback();
        ut=null;
      }
      Iterator keysIT = openedConnsHM.keySet().iterator();
      while(keysIT.hasNext()){
        String connId = (String)keysIT.next();
        Connection conn = (Connection)openedConnsHM.get(connId);
        if(useConnectionPool(connId)){
          ConnectionPool connPool = ConnectionPool.getConnectionPool(connId);
          /* 将活动连接返回到连接池 */
          connPool.returnConnection(conn);
        }else{
          /* 释放连接 */
          conn.close();
        }
      }
    }catch(JThinkRuntimeException e){
      throw e;
    }catch(Exception e){
      throw new JThinkRuntimeException(JThinkErrorCode.ERRCODE_DB_SQL_EXCEPTION, "事务关闭时发生异常!", e);
    }finally{   
      openedConnsHM.clear();
    }
   
  }
View Full Code Here

TOP

Related Classes of org.fto.jthink.exception.JThinkRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.