Unix Technical Forum

problem urgent - please help

This is a discussion on problem urgent - please help within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hi, I have just registered to the postgresql jdbc lidt and wanted to post a problem of mine which ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:50 AM
vbhatia@ksu.edu
 
Posts: n/a
Default problem urgent - please help

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


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:50 AM
Guy Rouillier
 
Posts: n/a
Default Re: problem urgent - please help

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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 12:50 AM
Michael Paesold
 
Posts: n/a
Default Re: problem urgent - please help

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/s...ql-listen.html
http://www.postgresql.org/docs/8.2/s...pq-notify.html
And for the JDBC interface:
http://jdbc.postgresql.org/documenta...tennotify.html

Perhaps that helps.

Best Regards
Michael Paesold

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:52 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com