Re: getNotifications - Mailing list pgsql-jdbc

From kfan
Subject Re: getNotifications
Date
Msg-id 1345220585174-5720235.post@n5.nabble.com
Whole thread Raw
In response to Re: getNotifications  (Maciek Sakrejda <m.sakrejda@gmail.com>)
Responses Re: getNotifications  (Maciek Sakrejda <m.sakrejda@gmail.com>)
List 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");
      stmt.close();
   }

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

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

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





--
View this message in context: http://postgresql.1045698.n5.nabble.com/getNotifications-tp5720228p5720235.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


pgsql-jdbc by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Re: getNotifications
Next
From: Maciek Sakrejda
Date:
Subject: Re: getNotifications