Re: Asynchronous notifications - Mailing list pgsql-jdbc

From Jean-Christophe ARNU
Subject Re: Asynchronous notifications
Date
Msg-id c1l30f$17jo$1@biggoron.nerim.net
Whole thread Raw
List 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 by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: RedHat Enterprise 3 and the JDBC driver
Next
From: Jean-Christophe ARNU
Date:
Subject: Asynchronous notifications