Object pgconn = ((com.caucho.sql.UserConnection) userconn).getConnection();
Object pgconn = ((UserConnection) userconn).getConnection();
  public static boolean pg_lo_export(Env env,                                     @NotNull Postgres conn,                                     int oid,                                     Path path)  {    try {      //@todo conn should be optional      // LargeObjectManager lobManager;      Object lobManager;      //org.postgresql.largeobject.LargeObjectManager      Class cl = Class.forName("org.postgresql.PGConnection");      Method method = cl.getDeclaredMethod("getLargeObjectAPI", null);      Object userconn = conn.getConnection();      Object pgconn = ((com.caucho.sql.UserConnection) userconn).getConnection();      lobManager = method.invoke(pgconn, new Object[] {});      // lobManager = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();      cl = Class.forName("org.postgresql.largeobject.LargeObjectManager");      method = cl.getDeclaredMethod("open", new Class[] {Integer.TYPE});      Object lobj = method.invoke(lobManager, new Object[] {oid});      cl = Class.forName("org.postgresql.largeobject.LargeObject");      method = cl.getDeclaredMethod("getInputStream", null);      Object isObj = method.invoke(lobj, new Object[] {});      InputStream is = (InputStream)isObj;      // Open the file      WriteStream os = path.openWrite();      // copy the data from the large object to the file      os.writeStream(is);      os.close();      is.close();      // Close the large object      method = cl.getDeclaredMethod("close", null);      method.invoke(lobj, new Object[] {});      return true;    } catch (Exception ex) {      log.log(Level.FINE, ex.toString(), ex);      return false;    }  }