Re: Asynchronous notifications

From: Jean-Christophe ARNU <jx(at)adorenepasetrederangeparlespamtuxfarm(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Asynchronous notifications
Date: 2004-02-26 15:19:25
Message-ID: c1l30f$17jo$1@biggoron.nerim.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I forgot my ListenNotify.jar test program : (sorry for cut/paste sources)...

//
// File: ListenNotify.java
// Author: J-C Arnu
// Time-stamp: <jeu, 26 fév 2004 11:42:02 by jc>
//
/*
*/
import java.sql.*;
public class ListenNotify{
public ListenNotify(){
try{
Driver drv =
((Driver)(Class.forName("org.postgresql.Driver")).newInstance());
Connection myDB =
DriverManager.getConnection("jdbc:postgresql://dev/supervisor?charSet=ISO-8859-1","sac30","");

Statement stt = myDB.createStatement();
stt.executeUpdate("LISTEN plop;");
while (true){
stt.execute("");
try{
Thread.sleep(250);
}
catch(Exception x){
}
SQLWarning w = stt.getWarnings();

while(w!=null){
System.out.println("Warning :"+w);
w=w.getNextWarning();
}

org.postgresql.PGNotification
notifications[]=((org.postgresql.PGConnection)myDB).getNotifications();
if (notifications!=null)
for(int i=0;i<notifications.length;i++)
System.out.println("Notification reçue :
"+notifications[i].getName());
}

}
catch(Exception ex){

System.out.println("-------------------------------------------");
ex.printStackTrace();

System.out.println("-------------------------------------------");

return;
}

}
public static void main(String args[]){
ListenNotify ln=new ListenNotify();
}
}

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andrew Holm-Hansen 2004-02-26 16:03:05 RedHat Enterprise 3 and the JDBC driver
Previous Message Andrew Lazarus 2004-02-26 14:59:35 Re: [JDBC] ΑΠ: ΑΠ: