Object pgconn = ((com.caucho.sql.UserConnection) userconn).getConnection();
Object pgconn = ((UserConnection) userconn).getConnection();
  public static ArrayValue pg_get_notify(Env env,                                         @NotNull Postgres conn,                                         @Optional("-1") int resultType)  {    try {      if (resultType > 0) {        throw new UnimplementedException("pg_get_notify with result type");      }      // org.postgresql.PGConnection      Class cl = Class.forName("org.postgresql.PGConnection");      // public PGNotification[] getNotifications() throws SQLException;      Method method = cl.getDeclaredMethod("getNotifications", null);      Object userconn = conn.getConnection();      Object pgconn = ((com.caucho.sql.UserConnection) userconn).getConnection();      // getNotifications()      Object notifications[] = (Object[]) method.invoke(pgconn, new Object[] {});      // org.postgresql.PGNotification      cl = Class.forName("org.postgresql.PGNotification");      // public String getName();      Method methodGetName = cl.getDeclaredMethod("getName", null);      // public int getPID();      Method methodGetPID = cl.getDeclaredMethod("getPID", null);      ArrayValueImpl arrayValue = new ArrayValueImpl();      int n = notifications.length;      StringValue k;      LongValue v;      for (int i=0; i<n; i++) {        // getName()        k = (StringValue) StringValue.create(methodGetName.invoke(notifications[i],                                                                  new Object[] {}));        // getPID()        v = (LongValue) LongValue.create((Integer) methodGetPID.invoke(notifications[i],                                                                       new Object[] {}));        arrayValue.put(k, v);      }      return arrayValue;    } catch (Exception ex) {      log.log(Level.FINE, ex.toString(), ex);      return null;    }  }