pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: findepi (@findepi) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3941: `ResultSetMetaData.getColumnClassName` returns incorrect class for NUMBER type
Date: Mon, 16 Feb 2026 16:32:26 +0000
Message-ID: <[email protected]> (raw)



**Describe the issue**

`java.sql.ResultSetMetaData.getColumnClassName` / `java.sql.ResultSet.getObject`  inconsistency.




**Driver Version?** 

42.7.10

**Java Version?**

25

**OS Version?**

MacOS 15.7.3 

**PostgreSQL Version?**

18

**To Reproduce**

```java
try (var container = new org.testcontainers.postgresql.PostgreSQLContainer("postgres:18")) {
    container.start();
    try (Connection connection = DriverManager.getConnection(container.getJdbcUrl(), container.getUsername(), container.getPassword());
            Statement statement = connection.createStatement()) {
        try (ResultSet resultSet = statement.executeQuery("SELECT '+Infinity'::decimal AS a")) {
            Class<?> clazz = Class.forName(resultSet.getMetaData().getColumnClassName(1));
            verify(resultSet.next());
            assertThat(resultSet.getObject(1)).isInstanceOf(clazz);
        }
    }
}
```


**Expected behaviour**

The contract for `getColumnClassName` is the following:

> Returns the fully-qualified name of the Java class whose instances are manufactured if the method ResultSet.getObject is called to retrieve a value from the column. ResultSet.getObject may return a subclass of the class returned by this method.

For NUMBER type, `getColumnClassName` returns `java.math.BigDecimal`.
However, `ResultSet.getObject` may sometimes return `java.lang.Double`, which obviously is not subclass of `java.math.BigDecimal`.

**proposed solution** return ``java.lang.Number`` from `getColumnClassName`


**Logs**

N/A


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3941: `ResultSetMetaData.getColumnClassName` returns incorrect class for NUMBER type
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox