Thread: LISTEN/NOTIFY support in JDBC driver?

LISTEN/NOTIFY support in JDBC driver?

From
Benjamin.Feinstein@guardent.com
Date:
Hello ya'll,

It appears that the current version of the JDBC interface for PostgreSQL
does not implement asyncronous client notifications. I have been able to
issue a NOTIFY statement through the JDBC driver, but I haven't found how to
LISTEN for an client notification. Am I missing something, or does the
JDBC-PgSQL interface not support LISTEN? Does anyone know of a patch to the
JDBC-PgSQL interface that enables the LISTEN functionality? I've looked back
through the list archives but was unable to find any threads in this topic.

I'm running:
PostgreSQL 7.1.3
jdbc7.1-1.2.jar
Sun JDK 1.3.1_01

Thanks for any help,
Ben

> Ben Feinstein
>   Software Development Engineer, R & D
>   W: 678.585.7865 x6726 F: 770.645.8311 M: 678.772.4126
>   8302 Dunwoody Pl., Suite 320, Atlanta, GA 30350 www.guardent.com
> _____________________________________________________
> G U A R D E N T
>   Enterprise Security and Privacy Programs
>
>

Re: LISTEN/NOTIFY support in JDBC driver?

From
Barry Lind
Date:
The jdbc driver does support notifications, but in a rather strange way.
  When the driver receives a notification is takes the notification
message and adds it to the list of warnings on the connection.  So the
way you get notifications is to call getWarnings().  Given that there
isn't a concept like notifications in the jdbc API, this is perhaps the
best way these can be handled within jdbc, unless someone can suggest a
better approach.

thanks,
--Barry

Benjamin.Feinstein@guardent.com wrote:

> Hello ya'll,
>
> It appears that the current version of the JDBC interface for PostgreSQL
> does not implement asyncronous client notifications. I have been able to
> issue a NOTIFY statement through the JDBC driver, but I haven't found how to
> LISTEN for an client notification. Am I missing something, or does the
> JDBC-PgSQL interface not support LISTEN? Does anyone know of a patch to the
> JDBC-PgSQL interface that enables the LISTEN functionality? I've looked back
> through the list archives but was unable to find any threads in this topic.
>
> I'm running:
> PostgreSQL 7.1.3
> jdbc7.1-1.2.jar
> Sun JDK 1.3.1_01
>
> Thanks for any help,
> Ben
>
>
>>Ben Feinstein
>>  Software Development Engineer, R & D
>>  W: 678.585.7865 x6726 F: 770.645.8311 M: 678.772.4126
>>  8302 Dunwoody Pl., Suite 320, Atlanta, GA 30350 www.guardent.com
>>_____________________________________________________
>>G U A R D E N T
>>  Enterprise Security and Privacy Programs
>>
>>
>>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>



Re: LISTEN/NOTIFY support in JDBC driver?

From
Benjamin.Feinstein@guardent.com
Date:
Hey ya'll,

Thanks for the quick reply, Barry!  I'm still having trouble getting the
notifications from the "SQLWarning Connection.getWarnings()" method.  When I
tried to execute multiple LISTEN statments, I get warnings like:

java.sql.SQLWarning: NOTICE:  Async_Listen: We are already listening on
event

However, I've never gotten a notification from the warnings. Yes, I am
sending the notifies from another connection to the same database. I've
attached my Java test program. Could you take a look and see what I'm doing
wrong?

Cheers,
Ben

-----Original Message-----
From: Barry Lind [mailto:barry@xythos.com]
Sent: Wednesday, January 09, 2002 10:10 PM
To: Ben Feinstein
Cc: pgsql-jdbc@postgresql.org
Subject: Re: LISTEN/NOTIFY support in JDBC driver?


The jdbc driver does support notifications, but in a rather strange way.
  When the driver receives a notification is takes the notification
message and adds it to the list of warnings on the connection.  So the
way you get notifications is to call getWarnings().  Given that there
isn't a concept like notifications in the jdbc API, this is perhaps the
best way these can be handled within jdbc, unless someone can suggest a
better approach.

thanks,
--Barry

Benjamin.Feinstein@guardent.com wrote:

> Hello ya'll,
>
> It appears that the current version of the JDBC interface for PostgreSQL
> does not implement asyncronous client notifications. I have been able to
> issue a NOTIFY statement through the JDBC driver, but I haven't found how
to
> LISTEN for an client notification. Am I missing something, or does the
> JDBC-PgSQL interface not support LISTEN? Does anyone know of a patch to
the
> JDBC-PgSQL interface that enables the LISTEN functionality? I've looked
back
> through the list archives but was unable to find any threads in this
topic.
>
> I'm running:
> PostgreSQL 7.1.3
> jdbc7.1-1.2.jar
> Sun JDK 1.3.1_01
>
> Thanks for any help,
> Ben
>
>
>>Ben Feinstein
>>  Software Development Engineer, R & D
>>  W: 678.585.7865 x6726 F: 770.645.8311 M: 678.772.4126
>>  8302 Dunwoody Pl., Suite 320, Atlanta, GA 30350 www.guardent.com
>>_____________________________________________________
>>G U A R D E N T
>>  Enterprise Security and Privacy Programs
>>
>>
>>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>



Attachment

Re: LISTEN/NOTIFY support in JDBC driver?

From
Barry Lind
Date:
Ben,

Since the jdbc driver doesn't poll the server, you would only see
notifications after interacting with the database in someother way.
Thus you will periodically need to issue queries to get the
notifications to be read.  (note I havn't tried this, but from looking
at the code this should be the case).

thanks,
--Barry



Benjamin.Feinstein@guardent.com wrote:

> Hey ya'll,
>
> Thanks for the quick reply, Barry!  I'm still having trouble getting the
> notifications from the "SQLWarning Connection.getWarnings()" method.  When I
> tried to execute multiple LISTEN statments, I get warnings like:
>
> java.sql.SQLWarning: NOTICE:  Async_Listen: We are already listening on
> event
>
> However, I've never gotten a notification from the warnings. Yes, I am
> sending the notifies from another connection to the same database. I've
> attached my Java test program. Could you take a look and see what I'm doing
> wrong?
>
> Cheers,
> Ben
>
> -----Original Message-----
> From: Barry Lind [mailto:barry@xythos.com]
> Sent: Wednesday, January 09, 2002 10:10 PM
> To: Ben Feinstein
> Cc: pgsql-jdbc@postgresql.org
> Subject: Re: LISTEN/NOTIFY support in JDBC driver?
>
>
> The jdbc driver does support notifications, but in a rather strange way.
>   When the driver receives a notification is takes the notification
> message and adds it to the list of warnings on the connection.  So the
> way you get notifications is to call getWarnings().  Given that there
> isn't a concept like notifications in the jdbc API, this is perhaps the
> best way these can be handled within jdbc, unless someone can suggest a
> better approach.
>
> thanks,
> --Barry
>
> Benjamin.Feinstein@guardent.com wrote:
>
>
>>Hello ya'll,
>>
>>It appears that the current version of the JDBC interface for PostgreSQL
>>does not implement asyncronous client notifications. I have been able to
>>issue a NOTIFY statement through the JDBC driver, but I haven't found how
>>
> to
>
>>LISTEN for an client notification. Am I missing something, or does the
>>JDBC-PgSQL interface not support LISTEN? Does anyone know of a patch to
>>
> the
>
>>JDBC-PgSQL interface that enables the LISTEN functionality? I've looked
>>
> back
>
>>through the list archives but was unable to find any threads in this
>>
> topic.
>
>>I'm running:
>>PostgreSQL 7.1.3
>>jdbc7.1-1.2.jar
>>Sun JDK 1.3.1_01
>>
>>Thanks for any help,
>>Ben
>>
>>
>>
>>>Ben Feinstein
>>> Software Development Engineer, R & D
>>> W: 678.585.7865 x6726 F: 770.645.8311 M: 678.772.4126
>>> 8302 Dunwoody Pl., Suite 320, Atlanta, GA 30350 www.guardent.com
>>>_____________________________________________________
>>>G U A R D E N T
>>> Enterprise Security and Privacy Programs
>>>
>>>
>>>
>>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>
>>
>>
>
>



Re: LISTEN/NOTIFY support in JDBC driver?

From
Benjamin.Feinstein@guardent.com
Date:
Hey all,

I've tried selecting from the db in between checking for warnings, but still
no luck?  Does anyone have JDBC code that issues a LISTEN, then reaps
notifications from the connection warnings?

Much thanks!,
Ben

-----Original Message-----
From: Barry Lind [mailto:barry@xythos.com]
Sent: Friday, January 11, 2002 12:58 PM
To: Ben Feinstein
Cc: pgsql-jdbc@postgresql.org
Subject: Re: LISTEN/NOTIFY support in JDBC driver?


Ben,

Since the jdbc driver doesn't poll the server, you would only see
notifications after interacting with the database in someother way.
Thus you will periodically need to issue queries to get the
notifications to be read.  (note I havn't tried this, but from looking
at the code this should be the case).

thanks,
--Barry



Benjamin.Feinstein@guardent.com wrote:

> Hey ya'll,
>
> Thanks for the quick reply, Barry!  I'm still having trouble getting the
> notifications from the "SQLWarning Connection.getWarnings()" method.  When
I
> tried to execute multiple LISTEN statments, I get warnings like:
>
> java.sql.SQLWarning: NOTICE:  Async_Listen: We are already listening on
> event
>
> However, I've never gotten a notification from the warnings. Yes, I am
> sending the notifies from another connection to the same database. I've
> attached my Java test program. Could you take a look and see what I'm
doing
> wrong?
>
> Cheers,
> Ben
>
> -----Original Message-----
> From: Barry Lind [mailto:barry@xythos.com]
> Sent: Wednesday, January 09, 2002 10:10 PM
> To: Ben Feinstein
> Cc: pgsql-jdbc@postgresql.org
> Subject: Re: LISTEN/NOTIFY support in JDBC driver?
>
>
> The jdbc driver does support notifications, but in a rather strange way.
>   When the driver receives a notification is takes the notification
> message and adds it to the list of warnings on the connection.  So the
> way you get notifications is to call getWarnings().  Given that there
> isn't a concept like notifications in the jdbc API, this is perhaps the
> best way these can be handled within jdbc, unless someone can suggest a
> better approach.
>
> thanks,
> --Barry
>
> Benjamin.Feinstein@guardent.com wrote:
>
>
>>Hello ya'll,
>>
>>It appears that the current version of the JDBC interface for PostgreSQL
>>does not implement asyncronous client notifications. I have been able to
>>issue a NOTIFY statement through the JDBC driver, but I haven't found how
>>
> to
>
>>LISTEN for an client notification. Am I missing something, or does the
>>JDBC-PgSQL interface not support LISTEN? Does anyone know of a patch to
>>
> the
>
>>JDBC-PgSQL interface that enables the LISTEN functionality? I've looked
>>
> back
>
>>through the list archives but was unable to find any threads in this
>>
> topic.
>
>>I'm running:
>>PostgreSQL 7.1.3
>>jdbc7.1-1.2.jar
>>Sun JDK 1.3.1_01
>>
>>Thanks for any help,
>>Ben
>>
>>
>>
>>>Ben Feinstein
>>> Software Development Engineer, R & D
>>> W: 678.585.7865 x6726 F: 770.645.8311 M: 678.772.4126
>>> 8302 Dunwoody Pl., Suite 320, Atlanta, GA 30350 www.guardent.com
>>>_____________________________________________________
>>>G U A R D E N T
>>> Enterprise Security and Privacy Programs
>>>
>>>
>>>
>>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>
>>
>>
>
>