예제 #1
0
  public void releaseConnectionIfSafe(BackendConnection conn, boolean debug, boolean needRollback) {
    RouteResultsetNode node = (RouteResultsetNode) conn.getAttachment();

    if (node != null) {
      if (this.autocommit || conn.isFromSlaveDB() || !conn.isModifiedSQLExecuted()) {
        releaseConnection(
            (RouteResultsetNode) conn.getAttachment(), LOGGER.isDebugEnabled(), needRollback);
      }
    }
  }
예제 #2
0
  public void releaseConnection(RouteResultsetNode rrn, boolean debug, final boolean needRollback) {

    BackendConnection c = target.remove(rrn);
    if (c != null) {
      if (debug) {
        LOGGER.debug("release connection " + c);
      }
      if (c.getAttachment() != null) {
        c.setAttachment(null);
      }
      if (!c.isClosed()) {
        if (c.isAutocommit()) {
          c.release();
        } else if (needRollback) {
          c.setResponseHandler(new RollbackReleaseHandler());
          c.rollback();
        } else {
          c.release();
        }
      }
    }
  }