Skip site navigation (1) Skip section navigation (2)

Re: getNotifications

From: kfan <kfan(dot)b1(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: getNotifications
Date: 2012-08-17 16:23:05
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Thank you for the assistance.

It's not an exception, it's a compile error.  I am casting the connection
object to a PGConnection...interesting to note though that the methods
available on the PGConnection object only shows the addDatatype method.  

the error: the method getNotifications() is undefined for type PGConnection.

What I see now is PGNotification is not available but PGConnection is...not
sure I saw that earlier.  Where is that class? Thought it was part of the
same package.

The code is something I found online:

import java.sql.*;
  Listener(Connection conn) throws SQLException {
      this.conn = conn;
      this.pgconn = (org.postgresql.PGConnection)conn;
      Statement stmt = conn.createStatement();
      stmt.execute("LISTEN mymessage");

   public void run() {
      while (true) {
         try {

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

            org.postgresql.PGNotification notifications[] =
            if (notifications != null) {
               for (int i=0; i<notifications.length; i++) {
                  System.out.println("Got notification: " +

View this message in context:
Sent from the PostgreSQL - jdbc mailing list archive at

In response to


pgsql-jdbc by date

Next:From: Maciek SakrejdaDate: 2012-08-17 16:43:10
Subject: Re: getNotifications
Previous:From: Maciek SakrejdaDate: 2012-08-17 15:53:44
Subject: Re: getNotifications

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group