Subject: [pgjdbc/pgjdbc] issue #3424: Using postgresql-42.7.4.jar triggers PSQLException

From: "mEkdal (@mEkdal)" <[email-masked]>
Date: Fri, 25 Oct 2024 13:33:57 +0000

When using postgresql-42.7.4.jar the "org.postgresql.util.PSQLException: Unknown value for ResultSet type
Unknown value for ResultSet type" is triggered.

Java version: openjdk version "1.8.0_422"
OS Version: Microsoft Windows 11 Home. 10.0.22631 Build 22631
PostgreSQL Version:  "PostgreSQL 13.12, compiled by Visual C++ build 1914, 64-bit"

Is works in a number of earlier versions up to postgresql-42.7.3.jar

The statement looks like this:
Statement stmt = conn.createStatement(ResultSet.CONCUR_READ_ONLY,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CLOSE_CURSORS_AT_COMMIT ); 

The values are the same in both 42.7.3 and 42.7.4 but fails in 42.7.4.
System.out.println(ResultSet.CONCUR_READ_ONLY+" "+ResultSet.TYPE_FORWARD_ONLY+" "+ResultSet.CLOSE_CURSORS_AT_COMMIT);
Result: 1007 1003 2

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Fri, 25 Oct 2024 14:02:33 +0000

Thanks for the report

Dave Cramer

On Fri, Oct 25, 2024 at 4:34 PM Michael Ekdal ***@***.***>
wrote:

> Statement stmt =
> conn.createStatement(ResultSet.CONCUR_READ_ONLY,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CLOSE_CURSORS_AT_COMMIT
> );
>
> System.out.println(ResultSet.CONCUR_READ_ONLY+"
> "+ResultSet.TYPE_FORWARD_ONLY+" "+ResultSet.CLOSE_CURSORS_AT_COMMIT);
> Result: 1007 1003 2
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/pgjdbc/pgjdbc/issues/3424>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AADDH5QEYCMP55CI3NRXJQTZ5JCFXAVCNFSM6AAAAABQTJU2LGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYYTIMJSG4YDMMY>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>

---

From: "mEkdal (@mEkdal)" <[email-masked]>
Date: Tue, 12 Nov 2024 13:37:57 +0000

package Jvakt;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class test07 {

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

        try (Connection con = DriverManager.getConnection(
                "jdbc:postgresql://localhost/Jvakt", "test", "test")) {
            Statement stmt = con.createStatement(ResultSet.CONCUR_READ_ONLY,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CLOSE_CURSORS_AT_COMMIT );
            
            	stmt.executeQuery("create table streamtable (bin text, str text)");
           	
            }
        }
    }

42.7.4.jar   =>
Exception in thread "main" org.postgresql.util.PSQLException: Unknown value for ResultSet type
	at org.postgresql.jdbc.PgStatement.<init>(PgStatement.java:166)
	at org.postgresql.jdbc.PgConnection.createStatement(PgConnection.java:1404)
	at Jvakt.test07.main(test07.java:16)

42.7.3.jar  =>
The table streamtable is created. I ignored the exeption below. 
Exception in thread "main" org.postgresql.util.PSQLException: No results were returned by the query.
	at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:252)
	at Jvakt.test07.main(test07.java:18)

---

From: "mEkdal (@mEkdal)" <[email-masked]>
Date: Thu, 29 May 2025 10:26:17 +0000

Testing 42.7.6.jar and the same error persists :) .

**This statement:**
_Statement stmt = conn.createStatement(ResultSet.CONCUR_READ_ONLY,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CLOSE_CURSORS_AT_COMMIT );_

**Trigger this error:**
_org.postgresql.util.PSQLException: Unknown value for ResultSet type
Unknown value for ResultSet type_

Thus not all types of resultset codes according to the manual is allowed since the problem appeared in 42.7.4.

BR
/Michael

---

From: "mEkdal (@mEkdal)" <[email-masked]>
Date: Mon, 09 Jun 2025 08:42:49 +0000

Changed the order of the parameters of the createStatement to conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY,ResultSet.HOLD_CURSORS_OVER_COMMIT );
and now it works.