Re: LISTEN/NOTIFY with JDBC

From: Kris Jurka <books(at)ejurka(dot)com>
To: Glenn Sullivan <glenn(dot)sullivan(at)varianinc(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: LISTEN/NOTIFY with JDBC
Date: 2004-05-13 08:58:40
Message-ID: Pine.BSO.4.56.0405130345490.31359@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 12 May 2004, Glenn Sullivan wrote:

> Thanks for the response. I have been using Sun's JDBC.
> Do I take it that I need to create and use the Postgres
> JDBC to get the ability to do NOTIFY/LISTEN?
>

You have been using the JDBC API provided by Sun as a number of interfaces
(java.sql.*) which are implemented behind the scenes by the postgresql
JDBC driver in concrete classes. Listen/Notify is a postgresql extension
not covered in the standard java.sql.* API, so must cast the standard
interfaces to postgresql implementations so that you can access the
additional functionality provided.

For example when using the postgresql JDBC driver java.sql.Connection is
actually an instance of org.postgresql.PGConnection, so you can cast your
Connection to a PGConnection to use the notification API. Unfortunately
the PGConnection and other extensions are either poorly documented or
completely undocumented. Combining my example with a brief look at the
source code for PGConnection and PGNotification should hopefully get you
going.

Kris Jurka

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Poslusny 2004-05-13 09:09:34 Re: Functionality in database or external langauge
Previous Message Stijn Vanroye 2004-05-13 07:53:23 Re: Cancel query based on a timeout