pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: kfan <kfan.b1@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: getNotifications
Date: Fri, 17 Aug 2012 09:23:05 -0700 (PDT)
Message-ID: <1345220585174-5720235.post@n5.nabble.com> (raw)
In-Reply-To: <CAOtHd0ARk_1LsfYUQfLgd-as_bkFpjyw4E_yyQTcQdDyJ6s8dg@mail.gmail.com>
References: <1345217428484-5720228.post@n5.nabble.com>
	<CAOtHd0ARk_1LsfYUQfLgd-as_bkFpjyw4E_yyQTcQdDyJ6s8dg@mail.gmail.com>

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.




view thread (13+ messages)  latest in thread

Message-ID: <1345220585174-5720235.post@n5.nabble.com>
Permalink:  ../1345220585174-5720235.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1345220585174-5720235.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: kfan.b1@gmail.com
  Subject: Re: getNotifications
  In-Reply-To: <1345220585174-5720235.post@n5.nabble.com>
  References: <1345217428484-5720228.post@n5.nabble.com> <CAOtHd0ARk_1LsfYUQfLgd-as_bkFpjyw4E_yyQTcQdDyJ6s8dg@mail.gmail.com> <1345220585174-5720235.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox