Skip site navigation (1) Skip section navigation (2)

Re: Constant "JTable" update

From: Ned Wolpert <ned(dot)wolpert(at)knowledgenet(dot)com>
To: Jean-Christophe ARNU <jc(dot)arnu(at)wanadoo(dot)fr>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Constant "JTable" update
Date: 2001-11-08 17:38:21
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Hash: SHA1

So, let me see if I understand correctly... you want your Java application
notifed when the table is updated, right?

You are correct that there isn't a JDBC api call that detects changes in the
database.  If I understand the question correctly, then your two main
solutions are :

1) Re-query the table often. (What your doing, and a drag to do. :-)

2) Write a trigger in the database to call an external application which
   notifies your Java clients that the table has been update.  This isn't a
   pure-java solution since the trigger can't be written in Java (yet) but it
   should work.  If you go this route, see
   for how to program triggers, specifically, will give you
   information on triggers and
   will give you information on procedural languages that can be used. (Perl
   is a good place to start. See
   for that. You'll still have to build the communications mechanism on how
   you want to notify your client (RMI, TCP, other) so the app the trigger
   calls can communicated with your Java-clients, but this at least gets you

(Side note for others: Nothing is wrong with having a trigger call a perl
 method that does an exec call, right?)

On 08-Nov-2001 Jean-Christophe ARNU wrote:
> Hello to all the pgJDBC communauty!
>       My problem seems to be quite simple to solve, but I would like to get
> you opinion on the different solutions available for the result to be
> programmed as nicer as it can :
>       My PostgreSQL database is used as a data storage for measure. On
> process "feeds" the database, inserting measure in a table (measure). On
> the other hand, I have a java program which is used to display such
> results in tables (or charts). Up to there, nothing seems to be easier.
> But I have to display data in "real time". The java program has to be
> notified that a new measure (or data content in the measure table) was
> inserted (repectively has changed).
>       The straightforward solution seems to have database listeners on the
> table that wakes-up a notifier in the java program. But such kind of
> mechanism seems not to be implemented in the JDBC API (up to my small
> knowledge).
>       The second tortuous solutions (the one I use) is to query the database
> relatively often to get the freshest results. This is quite bandwidth
> consumming (assuming that some users should use a quite small bandwidth
> connection). Using this kind of solution makes the Java application
> slow...
>       My questions are : is there any other solutions (Use of cursor maybe)?
> is the first solution can be implemented while combining JDBC et
> PostgreSQL functionnalities?
>       Thank you for any remarks/answers/attention paid/flames/rtfm for these
> problems.

Ned Wolpert <ned(dot)wolpert(at)knowledgenet(dot)com>

D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see


In response to

pgsql-jdbc by date

Next:From: Barry LindDate: 2001-11-08 17:46:31
Subject: Re: Memory exeception
Previous:From: Bruce MomjianDate: 2001-11-08 17:37:58
Subject: Re: MD5-based passwords

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group