Constant "JTable" update
Constant "JTable" update
От:
Jean-Christophe ARNU <jc.arnu@wanadoo.fr>
Дата:
>From - Return-Path: Delivered-To: jc@localhost.wanadoo.fr Received: from localhost (localhost [127.0.0.1]) by ez.wanadoo.fr (Postfix) with ESMTP id B9228F6C for ; Thu, 8 Nov 2001 17:42:08 -0500 (EST) Delivered-To: online.fr-jc.arnu@free.fr Received: from pop.free.fr by localhost with POP3 (fetchmail-5.7.4) for jc@localhost (single-drop); Thu, 08 Nov 2001 17:42:08 -0500 (EST) Received: (qmail 20741 invoked from network); 8 Nov 2001 16:28:12 -0000 Received: from celeborn.alyon.org (62.23.84.134) by mrelay1-1.free.fr with SMTP; 8 Nov 2001 16:28:12 -0000 Received: from postgresql.org (postgresql.org [64.49.215.8]) by celeborn.alyon.org (8.11.4/8.11.4) with ESMTP id fA8GSBa01655 for ; Thu, 8 Nov 2001 17:28:11 +0100 (Etc/GMT) Received: from postgresql.org (postgresql.org [64.49.215.8]) by postgresql.org (8.11.3/8.11.4) with SMTP id fA8Fwwm06218 for ; Thu, 8 Nov 2001 10:58:58 -0500 (EST) (envelope-from pgsql-jdbc-owner@postgresql.org) Date: Thu, 8 Nov 2001 10:58:58 -0500 (EST) Message-Id: <200111081558.fA8Fwwm06218@postgresql.org> MIME-Version: 1.0 X-Mailer: MIME-tools 5.41 (Entity 5.404) From: pgsql-jdbc-owner@postgresql.org To: Jean-Christophe ARNU Subject: Stalled post to pgsql-jdbc Content-Type: multipart/mixed; boundary="----------=_1005235138-96201-7" Status: X-Evolution-Source: pop://jc@localhost/inbox X-Evolution: 00000366-0020 This is a multi-part message in MIME format... ------------=_1005235138-96201-7 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Language: en Your message to pgsql-jdbc has been delayed, and requires the approval of the moderators, for the following reason(s): Non-Member Submission from Jean-Christophe ARNU If you do not wish the message to be posted, or have other concerns, please send a message to the list owners at the following address: pgsql-jdbc-owner@postgresql.org ------------=_1005235138-96201-7 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: binary Content-Description: Original message Received: from caroubier.wanadoo.fr (smtp-rt-6.wanadoo.fr [193.252.19.160]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA8Fiim05225 for ; Thu, 8 Nov 2001 10:44:47 -0500 (EST) (envelope-from arnu@paratronic.fr) Received: from mel-rta8.wanadoo.fr (193.252.19.79) by caroubier.wanadoo.fr; 8 Nov 2001 16:44:45 +0100 Received: from ez (217.128.2.57) by mel-rta8.wanadoo.fr; 8 Nov 2001 16:43:02 +0100 Subject: Constant "JTable" update From: Jean-Christophe ARNU To: pgsql-jdbc@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/0.12 (Preview Release) Date: 08 Nov 2001 16:38:35 -0500 Message-Id: <1005255525.2065.38.camel@ez> Mime-Version: 1.0 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. -- Jean-Christophe ARNU s/w developer Paratronic France
Re: Constant "JTable" update
От:
Ned Wolpert <ned.wolpert@knowledgenet.com>
Дата:
-----BEGIN PGP SIGNED MESSAGE----- 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 http://www.postgresql.org/idocs/index.php?programmer-server.html for how to program triggers, specifically, http://www.postgresql.org/idocs/index.php?triggers.html will give you information on triggers and http://www.postgresql.org/idocs/index.php?programmer-pl.html will give you information on procedural languages that can be used. (Perl is a good place to start. See http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html 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 started. (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. > Virtually, Ned Wolpert D08C2F45: 28E7 56CB 58AC C622 5A51 3C42 8B2B 2739 D08C 2F45 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE76sMNiysnOdCML0URAumfAJ0QLfz1DpEZcFxK4aNMX3sxTaYckwCfdkmb 1NIgWK4dJTyo2piyzH6Zjhk= =Yx6P -----END PGP SIGNATURE-----