Documentation on NOTIFY/LISTEN is misleading

From: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Documentation on NOTIFY/LISTEN is misleading
Date: 2017-03-11 05:44:03
Message-ID: 41ED3F5450C90F4D8381BC4D8DF6BBDCAF69CAC9@EXCHANGESERVER.ikoffice.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jorge Solorzano 2017-03-15 12:52:08 [pgjdbc/pgjdbc] 3f2a02: test: check that new properties follow correct low...
Previous Message Vladimir Sitnikov 2017-03-08 17:28:01 [pgjdbc/pgjdbc] 9c80ad: fix: make sure org.postgresql.Driver is loaded whe...