Understanding DateStyle guc in startup packet - Mailing list pgsql-jdbc

From Manav Kumar
Subject Understanding DateStyle guc in startup packet
Date
Msg-id CAPhCW+-oyivUiBiP5nOMQNxQzXLnT62SvCZ1oq7rqZkHq34KGA@mail.gmail.com
Whole thread Raw
Responses Re: Understanding DateStyle guc in startup packet
List pgsql-jdbc

Manav Kumar mkumar@yugabyte.com

Sat, May 17, 6:05 PM (2 days ago)
to pgsql-bugs
Hi Team,
I'm writing to clarify a syntax to pass the guc options in the startup packt of the connection via JDBC. 


Wrote below small java program:

Properties props = new Properties();
props.setProperty("options", "-c DateStyle=Postgres,DMY");
props.setProperty("user", "postgres");
props.setProperty("password", "postgres");
connection = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/postgres", props);

stmt1 = connection.createStatement();
ResultSet rs = stmt1.executeQuery("show DateStyle");
while (rs.next()) {
System.out.println(rs.getString(1));
}
stmt1.execute("reset DateStyle");
rs = stmt1.executeQuery("show DateStyle");
while (rs.next()) {
System.out.println(rs.getString(1));
}

The output I'm getting is:
ISO, DMY
ISO, DMY.

As explained by @Laurenz Albe  the driver forces the value of DateStyle to remain ISO even though the client tries to set a different value in the startup packet.

Can you please point me in the code where it happens or share briefly how it has been implemented. I was testing a connection pool with pg and saw the Postgres,DMY (client provided value) values coming in the startup packet.

Best,
Manav

pgsql-jdbc by date:

Previous
From: Laurenz Albe
Date:
Subject: Fwd: PostgreSQL JDBC 42.7.5 returns an unexpected catalog name
Next
From: Vladimir Sitnikov
Date:
Subject: Re: Understanding DateStyle guc in startup packet