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: 1345220585174-5720235.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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");
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.

In response to

Responses

Browse pgsql-jdbc by date

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