Re: Asynchronous notifications
От | Jean-Christophe ARNU |
---|---|
Тема | Re: Asynchronous notifications |
Дата | |
Msg-id | c1l30f$17jo$1@biggoron.nerim.net обсуждение исходный текст |
Список | 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(); } }
В списке pgsql-jdbc по дате отправления: