pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
problem urgent - please help
3+ messages / 3 participants
[nested] [flat]

* problem urgent - please help
@ 2007-07-28 02:00  vbhatia@ksu.edu
  0 siblings, 1 reply; 3+ messages in thread

From: vbhatia@ksu.edu @ 2007-07-28 02:00 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

I have just registered to the postgresql jdbc lidt and wanted to post a
problem of mine which is very urgent to solve, so please help me out.

I have written a Java application that reads the data from a postgresql
database and retrieves a particular field, performs some actions on
that field and finally store the calculated data in some other
table.The postgresql database, however is changing continuously , since
new data is being added every minute. My problem is that I want to
write some trigger in my java application that would be invoked as soon
as there is a change in the database and perform the above actions for
that newly added row.

Is this even possible using a Java application, if yes please guide me
how to do this, if no , what can be another way to read the data
dynamically from a database through a Java application.

Please help me as I am in midst of a project and have been digging into
this for quite long without any productive results.

Regards,
Vishal Bhatia




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: problem urgent - please help
@ 2007-07-28 04:42  Guy Rouillier <guyr-ml1@burntmail.com>
  parent: vbhatia@ksu.edu
  0 siblings, 1 reply; 3+ messages in thread

From: Guy Rouillier @ 2007-07-28 04:42 UTC (permalink / raw)
  To: pgsql-jdbc

vbhatia@ksu.edu wrote:
> I have written a Java application that reads the data from a postgresql
> database and retrieves a particular field, performs some actions on
> that field and finally store the calculated data in some other
> table.The postgresql database, however is changing continuously , since
> new data is being added every minute. My problem is that I want to
> write some trigger in my java application that would be invoked as soon
> as there is a change in the database and perform the above actions for
> that newly added row.

You can write a trigger in Java.  If you're asking if a trigger in 
PostgreSQL can invoke your standalone Java program, the short answer is 
no.  You can probably rig something up using an untrusted PL language, 
though.  There is no untrusted Java implementation, though, so you'd 
have to use another one to implement the glue code.  Sounds like your 
best bet would be to write a trigger in Java, and just run the whole 
thing in the DB.

-- 
Guy Rouillier



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: problem urgent - please help
@ 2007-07-28 07:01  Michael Paesold <mpaesold@gmx.at>
  parent: Guy Rouillier <guyr-ml1@burntmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paesold @ 2007-07-28 07:01 UTC (permalink / raw)
  To: vbhatia@ksu.edu; +Cc: pgsql-jdbc

Guy Rouillier wrote:
> vbhatia@ksu.edu wrote:
>> I have written a Java application that reads the data from a postgresql
>> database and retrieves a particular field, performs some actions on
>> that field and finally store the calculated data in some other
>> table.The postgresql database, however is changing continuously , since
>> new data is being added every minute. My problem is that I want to
>> write some trigger in my java application that would be invoked as soon
>> as there is a change in the database and perform the above actions for
>> that newly added row.
> 
> You can write a trigger in Java.  If you're asking if a trigger in 
> PostgreSQL can invoke your standalone Java program, the short answer is 
> no.  You can probably rig something up using an untrusted PL language, 
> though.  There is no untrusted Java implementation, though, so you'd 
> have to use another one to implement the glue code.  Sounds like your 
> best bet would be to write a trigger in Java, and just run the whole 
> thing in the DB.

Another option would be to use LISTEN/NOTIFY. You would have a Java thread 
LISTENING on events, and use triggers on tables (e.g. using PL/pgSQL) to 
NOTIFY the thread on updates. Than the Java code can do what ever is needed.

See the documentation (Server):
http://www.postgresql.org/docs/8.2/static/sql-listen.html
http://www.postgresql.org/docs/8.2/static/libpq-notify.html
And for the JDBC interface:
http://jdbc.postgresql.org/documentation/82/listennotify.html

Perhaps that helps.

Best Regards
Michael Paesold



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-07-28 07:01 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-07-28 02:00 problem urgent - please help vbhatia@ksu.edu
2007-07-28 04:42 ` Guy Rouillier <guyr-ml1@burntmail.com>
2007-07-28 07:01   ` Michael Paesold <mpaesold@gmx.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox