code: public static void returnConnection(Connection conn) throws SQLException {
          if (conn == null) {
              return;
          }
          String dsName = openConnDsName.get().get(conn);
          OpenConnStats connStats = dsName != null ? openConnStats.get().get(dsName) : null;
          if (connStats == null) {
              conn.close();
          } else {
              long value = connStats.counter.decrementAndGet();
              if (value <= 0) {
                  try {
                      try {
                          if (connStats.inTransaction) {
                              conn.commit();
                          }
                      } catch (Exception e) {
                          conn.rollback();
                      } finally {
                          try {
                              conn.setAutoCommit(true);
                          } finally {
                              connStats.inTransaction = false;
                              conn.close();
                          }
                      }
                  } finally {
                      openConnStats.get().remove(dsName);
                      openConnDsName.get().remove(conn);
                  }
              }
          }
      }
docs: Returns a JDBC connection obtained from {@link #getConnection(String)}.
  
  @param conn
  @throws SQLException