[JDBC] Documentation on NOTIFY/LISTEN is misleading - Mailing list pgsql-jdbc

From Daniel Migowski
Subject [JDBC] Documentation on NOTIFY/LISTEN is misleading
Date
Msg-id 41ED3F5450C90F4D8381BC4D8DF6BBDCAF69CAC9@EXCHANGESERVER.ikoffice.de
Whole thread Raw
List pgsql-jdbc

Hello,

 

I found the example code in the documentation of the JDBC driver is misleading. The example receiving code displayed on https://jdbc.postgresql.org/documentation/head/listennotify.html issues a SELECT 1 everytime before it checks for notifications, which made me believe the driver is not able to receive notifications without having to hit the database.

 

After checking the source (because I tried to implement something that does not have this requirement) I found out this select is useless at least in the current state of the driver, which makes the drivers implementation much more appealing to me. Please remove the seven lines

 

                // issue a dummy query to contact the backend
                // and receive any pending notifications.

 

                Statement stmt = conn.createStatement();

                ResultSet rs = stmt.executeQuery("SELECT 1");

                rs.close();

                stmt.close();

 

from the example code.

 

Regards,

Daniel Migowski

 

pgsql-jdbc by date:

Previous
From: Vladimir Sitnikov
Date:
Subject: [pgjdbc/pgjdbc] 9c80ad: fix: make sure org.postgresql.Driver isloaded whe...
Next
From: Jorge Solorzano
Date:
Subject: [JDBC] [pgjdbc/pgjdbc] 3f2a02: test: check that new properties followcorrect low...