LISTEN/NOTIFY with JDBC

From: Glenn Sullivan <glenn(dot)sullivan(at)varianinc(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: LISTEN/NOTIFY with JDBC
Date: 2004-05-11 22:10:51
Message-ID: 40A14F6B.8090704@varianinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Cohen 2004-05-11 22:34:38 Shared memory segment error
Previous Message Jonathan Bartlett 2004-05-11 21:06:51 Re: bytea