From: | Jorge Solórzano <jorsol(at)gmail(dot)com> |
---|---|
To: | Oleg Golovanov <rentech(at)mail(dot)ru> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: How to get DB connection PID from JDBC |
Date: | 2022-09-12 13:03:03 |
Message-ID: | CA+cVU8NOyYHGYS34jS6s3h1TnXjNtnpwQfrcVf9J2q8=N0zG6A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi Oleg,
Maybe you can use the extensions to the JDBC API:
try (Connection conn =
DriverManager.getConnection(getJdbcUrl(), getUsername(),
getPassword())) {
PGConnection pgconn =
conn.unwrap(org.postgresql.PGConnection.class);
System.out.println(pgconn.getBackendPID());
}
Regards,
On Mon, Sep 12, 2022 at 11:14 AM Oleg Golovanov <rentech(at)mail(dot)ru> wrote:
>
> Hello
>
> There was a need for logging purposes to receive in a Java / Spring application using JDBC, the PID of the connection on the database side. I did not find such an opportunity in the JDBC sources.
>
> Can you explain if there is such a possibility?
>
> It seems to me to execute when establishing a connection each time a request
> select pg_backend_pid()
> not the best idea.
>
> Best Regards,
>
> Oleg Golovanov
> Tel./WhatsApp +79067778133
> Moscow, Russia
>
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2022-09-14 00:11:16 | [pgjdbc/pgjdbc] f4b8a0: Ignore simplequery for postgresql 8.4 (#2614) |
Previous Message | Oleg Golovanov | 2022-09-12 09:13:49 | How to get DB connection PID from JDBC |