Обсуждение: Set application name from jdbc url
Hi,
I want to set the application name of the connections of my application.
Then I can list the rows in `pg_stat_activity` with a non empty
`application_name` column.
I have setup the following JDBC url for connecting to my Postgresql
database:
jdbc:postgresql://localhost:5435/MyDB?application-name=MyApp
I have tried also this url with no more success.
jdbc:postgresql://localhost:5435/MyDB?application_name=MyApp
I also tried these two variant of application name parameter :
*applicationName* and *ApplicationName* with no luck.
What is the correct parameter name ?
Here is my JDBC driver version: **9.1-901.jdbc4**
I try to connect a Postgresql server : 9.2.4 - 64bit - running on Windows 7
Stephan
> What is the correct parameter name ? Try "ApplicationName" [1]. Also, you can set it on the Connection object after creation via the JDBC standard setClientInfo(...) method[2]. [1]: https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/core/v3/ConnectionFactoryImpl.java#L639 [2]: http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setClientInfo%28java.lang.String,%20java.lang.String%29 -S
The solution from [2] works like a charm.
However, the solution from [1] doesn't work :\
I have set up a database connection from the Datasource explorer in Eclipse,
with the following JDBC url:
jdbc:postgresql://localhost:5435/REC?ApplicationName=ZOZOZOZ
From pgAdmin III, here are the results of the following query : select
pid, application_name from pg_stat_activity
9212;""
6396;""
4628;"psql"
6796;"pgAdmin III - Navigateur"
The results of the same query running from psql:
pid | application_name
------+-------------------------------------
9212 |
6396 |
4628 | psql
6796 | pgAdmin III - Navigateur
I have tried to set up a connection manually and I get the same similar
results: ZOZOZOZ seems to be an unknown application name.
Le 17/10/2013 15:44, Sehrope Sarkuni a écrit :
>> What is the correct parameter name ?
> Try "ApplicationName" [1]. Also, you can set it on the Connection
> object after creation via the JDBC standard setClientInfo(...)
> method[2].
>
> [1]: https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/core/v3/ConnectionFactoryImpl.java#L639
> [2]:
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setClientInfo%28java.lang.String,%20java.lang.String%29
>
> -S
Try it with the latest version of the JDBC driver (currently 9.2-1003-jdbc4). Maybe your older driver is causing the issue (above says you're using v9.1-904). I'm able to test setting the client name and verify it via pg_stat_activity using the latest driver connecting to 9.1, 9.2, and 9.3. I tried it via a URL property, setClientInfo(...), and explicitly setting a java.util.Property value and all three worked fine. -S On Thu, Oct 17, 2013 at 10:11 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote: > The solution from [2] works like a charm. > > However, the solution from [1] doesn't work :\ > > I have set up a database connection from the Datasource explorer in Eclipse, > with the following JDBC url: > > jdbc:postgresql://localhost:5435/REC?ApplicationName=ZOZOZOZ > > From pgAdmin III, here are the results of the following query : select pid, > application_name from pg_stat_activity > > 9212;"" > 6396;"" > 4628;"psql" > 6796;"pgAdmin III - Navigateur" > > The results of the same query running from psql: > > pid | application_name > ------+------------------------------------- > 9212 | > 6396 | > 4628 | psql > 6796 | pgAdmin III - Navigateur > > I have tried to set up a connection manually and I get the same similar > results: ZOZOZOZ seems to be an unknown application name. > > Le 17/10/2013 15:44, Sehrope Sarkuni a écrit : > >>> What is the correct parameter name ? >> >> Try "ApplicationName" [1]. Also, you can set it on the Connection >> object after creation via the JDBC standard setClientInfo(...) >> method[2]. >> >> [1]: >> https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/core/v3/ConnectionFactoryImpl.java#L639 >> [2]: >> http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setClientInfo%28java.lang.String,%20java.lang.String%29 >> >> -S > > >
Le 17/10/2013 16:54, Sehrope Sarkuni a écrit :
Some of our clients may need 9.2-1003-jdbc3.
Do you know of any maven repository delivering this version ?
I use maven and I have found the driver here http://mvnrepository.com/artifact/org.postgresql/postgresql/9.2-1003-jdbc4.Try it with the latest version of the JDBC driver (currently 9.2-1003-jdbc4).
Some of our clients may need 9.2-1003-jdbc3.
Do you know of any maven repository delivering this version ?
maven central
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>VERSION</version>
</dependency>On Fri, Oct 18, 2013 at 7:12 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:
Le 17/10/2013 16:54, Sehrope Sarkuni a écrit :I use maven and I have found the driver here http://mvnrepository.com/artifact/org.postgresql/postgresql/9.2-1003-jdbc4.Try it with the latest version of the JDBC driver (currently 9.2-1003-jdbc4).
Some of our clients may need 9.2-1003-jdbc3.
Do you know of any maven repository delivering this version ?
Le 18/10/2013 14:18, Dave Cramer a écrit :
The version 9.2-1003-jdbc3 is not deployed on the maven central yet.maven central<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>VERSION</version> </dependency>
Stephan,
Apologies, only jdbc4 is on there. I gather you require jdbc3 ?
On Fri, Oct 18, 2013 at 8:57 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:
Le 18/10/2013 14:18, Dave Cramer a écrit :The version 9.2-1003-jdbc3 is not deployed on the maven central yet.maven central<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>VERSION</version> </dependency>
Le 18/10/2013 14:59, Dave Cramer a écrit : > Apologies, only jdbc4 is on there. I gather you require jdbc3 ? > I need this version. I quite don't understand why it is not deployed on central like jdbc4.
Well the project never really did use maven and I have only had requests for jdbc4 to be pushed to maven. Now I have a reason to do jdbc3
On Fri, Oct 18, 2013 at 9:02 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:
Le 18/10/2013 14:59, Dave Cramer a écrit :I need this version. I quite don't understand why it is not deployed on central like jdbc4.Apologies, only jdbc4 is on there. I gather you require jdbc3 ?
> Well the project never really did use maven and I have only had > requests for jdbc4 to be pushed to maven. Now I have a reason to do jdbc3 > How many days do you need for pushing this version to maven ?
Stephan,
My challenge is mostly finding a machine that I can push from and build jdbc3. Assuming those two are possible I may be able to do this next week.
On Fri, Oct 18, 2013 at 9:34 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:
How many days do you need for pushing this version to maven ?Well the project never really did use maven and I have only had requests for jdbc4 to be pushed to maven. Now I have a reason to do jdbc3
I can set something up for this if need be. I am not sure what I would need to submit to maven central but I can do that as well if I can get some instruction.
On Oct 18, 2013 9:15 AM, "Dave Cramer" <pg@fastcrypt.com> wrote:
Stephan,My challenge is mostly finding a machine that I can push from and build jdbc3. Assuming those two are possible I may be able to do this next week.On Fri, Oct 18, 2013 at 9:34 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:How many days do you need for pushing this version to maven ?Well the project never really did use maven and I have only had requests for jdbc4 to be pushed to maven. Now I have a reason to do jdbc3
OK, there is a thread on the list somewhere with instructions.
This would be awesome if you could help out
On Fri, Oct 18, 2013 at 10:20 AM, Kevin Carr <kscarr73@gmail.com> wrote:
I can set something up for this if need be. I am not sure what I would need to submit to maven central but I can do that as well if I can get some instruction.
On Oct 18, 2013 9:15 AM, "Dave Cramer" <pg@fastcrypt.com> wrote:Stephan,My challenge is mostly finding a machine that I can push from and build jdbc3. Assuming those two are possible I may be able to do this next week.On Fri, Oct 18, 2013 at 9:34 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:How many days do you need for pushing this version to maven ?Well the project never really did use maven and I have only had requests for jdbc4 to be pushed to maven. Now I have a reason to do jdbc3
Ok guys,
I'll have a look at Maven Central and this list for any anouncement ;)
Le 18/10/2013 16:20, Kevin Carr a écrit :
I'll have a look at Maven Central and this list for any anouncement ;)
Le 18/10/2013 16:20, Kevin Carr a écrit :
I can set something up for this if need be. I am not sure what I would need to submit to maven central but I can do that as well if I can get some instruction.
On Oct 18, 2013 9:15 AM, "Dave Cramer" <pg@fastcrypt.com> wrote:Stephan,My challenge is mostly finding a machine that I can push from and build jdbc3. Assuming those two are possible I may be able to do this next week.On Fri, Oct 18, 2013 at 9:34 AM, Stéphan BEUZE <stephan.beuze@douane.finances.gouv.fr> wrote:How many days do you need for pushing this version to maven ?Well the project never really did use maven and I have only had requests for jdbc4 to be pushed to maven. Now I have a reason to do jdbc3