Subject: [pgjdbc/pgjdbc] issue #3508: Application Name is never set for assume min server version >= 9.0

From: "joejensen (@joejensen)" <[email-masked]>
Date: Tue, 04 Feb 2025 22:04:32 +0000

**Describe the issue**
As of 42.7.5 the ApplicationName is never set unless the assume min server version is set to a value < 9.0.

The code that set the application name for versions >= 9.0 appears to have been removed in https://github.com/pgjdbc/pgjdbc/pull/3476

The comment indicates that the removed behavior is duplicated by runInitialQueries, however, that method returns immediately if the server version is >= 9.

No including this in the initial connection also has a negative impact on the connection logging as previously reported on: https://github.com/pgjdbc/pgjdbc/issues/2111

**Driver Version?** 
42.7.5

**Java Version?**
17 but not relevant

**OS Version?**
Windows but not relevant

**PostgreSQL Version?**
17.2

**To Reproduce**
Create a jdbc connection with 42.7.5, using the application ApplicationName option and the assumMinServerVersion=17 option.

**Expected behaviour**
Expect the application name to be set to the provided ApplicationName, however, it is instead set to blank / left unset.

**Logs**
If possible PostgreSQL logs surrounding the occurrence of the issue
Additionally logs from the driver can be obtained adding

Using the following template code make sure the bug can be replicated in the driver alone.
```
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

public class TestNullsFirst {
    public static void main(String []args) throws Exception {

        String url = "jdbc:postgresql://localhost:5432/test";

        Properties props = new Properties();
        props.setProperty("user", "test");
        props.setProperty("password", "test");
        try ( Connection conn = DriverManager.getConnection(url, props) ){
            try ( Statement statement = conn.createStatement() ) {
                try (ResultSet rs = statement.executeQuery( "select lastname from users order by lastname asc nulls first") ){
                    if (rs.next())
                        System.out.println( "Get String: " + rs.getString(1));
                }
            }
        }
    }
}
```

---

From: "lfgcampos (@lfgcampos)" <[email-masked]>
Date: Wed, 14 May 2025 08:22:31 +0000

I have no idea how the release cadence works but is there a plan to release this fix soon-ish? 😄

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Wed, 14 May 2025 10:10:36 +0000

I'm hopeful in the next few weeks