Re: Asynchronous notifications

Поиск
Список
Период
Сортировка
Искать

Re: Asynchronous notifications

От:
Jean-Christophe ARNU <jx@adorenepasetrederangeparlespamtuxfarm.org>
Дата:
I forgot my ListenNotify.jar test program : (sorry for cut/paste sources)...


//
// File:       ListenNotify.java
// Author:     J-C Arnu
// Time-stamp: 
//
/*
*/
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
FAQ