LISTEN/NOTIFY with JDBC - Mailing list pgsql-general

From Glenn Sullivan
Subject LISTEN/NOTIFY with JDBC
Date
Msg-id 40A14F6B.8090704@varianinc.com
Whole thread Raw
Responses Re: LISTEN/NOTIFY with JDBC  (Kris Jurka <books@ejurka.com>)
List pgsql-general
Hi,

I have been trying to get LISTEN/NOTIFY working in with JDBC.  I cannot seem
to get notified.  I looked in the e-mail archive and saw a lot of similiar
questions a couple of years ago.  I never could find any answers in the
e-mail nor in the documentation.  Perhaps I just missed it.

I have tried the following code snipit:

Connection db = DriverManager.getConnection(url, user, passwd);
Statement sql = db.createStatement();

sql.execute("LISTEN mytest");
db.clearWarnings();

for(int i=0; i < 10 ; i ++) {
     Thread.sleep(3000);
     SQLWarning warn = db.getWarnings();
     if(warn != null)
         System.out.println("warn: " + warn.getMessage());
     else
         System.out.println("warning null");
}


During the running of this loop, I run "psql" on the same database
and manually execute "NOTIFY mytest;".

"warn" always comes back "null"

Could someone help me figure out what is wrong with this, or point me in
a new direction?

Thanks,

Glenn


pgsql-general by date:

Previous
From: Robert Treat
Date:
Subject: Re: How to move data from 1 database to another?
Next
From: Alexander Cohen
Date:
Subject: Shared memory segment error