public static void returnConnection(Connection conn) {
   try {
     // pool.returnObject(conn);
     conn.close();
   } catch (Exception ex) {
     PGException.pgThrow(ex, "Error when return SQL connection");
   }
 }
  public static Connection get() {

    try {
      // return pool.borrowObject();
      return dataSource.getConnection();
    } catch (Exception ex) {
      PGException.pgThrow(ex, "Cannot get SQL connection");
    }

    return null;
  }
Ejemplo n.º 3
0
  @Override
  public void deser(Map<String, Object> json) {
    for (Map.Entry<String, Object> tmpEntry : json.entrySet()) {
      String fieldName = tmpEntry.getKey();
      Object value = tmpEntry.getValue();

      Field field = FieldUtils.getField(getClass(), fieldName, true);
      if (field != null) {
        Class<?> fldClass = field.getType();
        if (CONVERTERS.containsKey(fldClass)) {
          try {
            Function<Object, Object> converter = CONVERTERS.get(fldClass);
            field.set(this, converter.apply(value));
          } catch (IllegalArgumentException ex) {
            PGException.pgThrow(ex, "Invalid convert");
          } catch (IllegalAccessException ex) {
            PGException.pgThrow(ex, "Invalid convert");
          }
        }
      }
    }
  }
  public V get(K key) {
    V v = cache.getIfPresent(key);
    if (v == null) {
      try {
        lockManager.hold(locks, key);
        if (v == null) {
          v = loader.load(key);
          cache.put(key, v);
        }
      } catch (Exception ex) {
        PGException.pgThrow(ex);
      } finally {
        lockManager.release(locks, key);
      }
    }

    return v;
  }