RE: [INTERFACES] NOTIFY/LISTEN with JDBC

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: "'Martin Kresse'" <mkresse(at)slyde(dot)in-berlin(dot)de>, pgsql-interfaces(at)postgresql(dot)org
Subject: RE: [INTERFACES] NOTIFY/LISTEN with JDBC
Date: 2000-02-10 08:42:51
Message-ID: 1B3D5E532D18D311861A00600865478C70C1A2@exchange1.nt.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I'll try it. That should work (in theory).

Peter

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.

-----Original Message-----
From: Martin Kresse [mailto:mkresse(at)slyde(dot)in-berlin(dot)de]
Sent: Thursday, February 10, 2000 8:28 AM
To: pgsql-interfaces(at)postgreSQL(dot)org
Subject: [INTERFACES] NOTIFY/LISTEN with JDBC

Hi there,

I'm writing a database application in Java, which needs to get
notified about changes in the database. Therefore I'd like to use the
NOTIFY/LISTEN mechanism, but I can't get it working with JDBC. I
was told, to use connection.getWarnings() method to retrieve
notifications, which doesn't seem to work. I'm using PostgreSQL
6.5.1 with the JDBC-Driver 6.5 for jdk1.1, and the following code
doesn't produce any output, while a parallel running psql-shell
displays the notifications...

Connection c = DriverManager.getConnection(...);
Statement s = c.createStatement();
s.execute("LISTEN test");

while(true) {
s.execute("NOTIFY test");
SQLWarning w = c.getWarnings();
if (w != null)
System.out.println(w.getMessage());
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {}
}

Am I doing something wrong?
Thanks a lot for your help,

Martin Kresse

************

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Mount 2000-02-10 08:46:23 RE: [INTERFACES] JDBC primary keys
Previous Message Martin Kresse 2000-02-10 08:28:05 NOTIFY/LISTEN with JDBC