aspose file tools*
The moose likes Java in General and the fly likes Fire a trigger from an external application on database update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Fire a trigger from an external application on database update" Watch "Fire a trigger from an external application on database update" New topic
Author

Fire a trigger from an external application on database update

Pratik Lohia
Ranch Hand

Joined: May 05, 2005
Posts: 88
I got this problem... and I dunno which forum to put it in.

i got a Java application which will update data in a certain database table.
Now when this table is updated, an external application should be called, which will pick up this data and send it to MQ.

I need to know, how can i trigger this event to pick up the data from the database table, whenever an update is fired on the table from my Java appliation.
I am using WSAD 5.1 as my developer. My application is deployed on WAS 5.1 on a Linux box. The database server is DB2. I use Websphere MQ 5.1 for my queues.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18152
    
    8

So, in effect you are asking how to configure DB2 to run a trigger when a record in a certain table is updated. The fact that it's JDBC that is doing the updating is irrelevant. This is a question about DB2. (Unless, perhaps, you only want the trigger to be called when your Java program does the updating. In which case you should just have the Java program do the updating and send the message to MQ, and forget about triggers.)

Here's the first entry returned from my internet query about "DB2 trigger":

http://www-128.ibm.com/developerworks/db2/library/techarticle/0308bhogal/0308bhogal.html

It doesn't show how to send data to MQ in that article, but I would assume the DB2 help system would have plenty of information. In my experience IBM products always have large volumes of help text available.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Is it possible for the Java app doing the DB update to then send a JMS message (containing the PK) for a message listener to process? I'd prefer this solution as it doesn't tie you into a particular DB.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
That's how I read the question, too. You can even put the database update and the send in the same transaction so if the send fails the database update rolls back. If that's what you want.
[ December 25, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Pratik Lohia
Ranch Hand

Joined: May 05, 2005
Posts: 88
Thanks for all the help guys...
There are a few more points...

1. In my application say 'A1', the user will fire a request to send data to MQ. There is a possibility the user will log out after that.

2. Now, the amount of data that needs to be processed and sent to MQ is very large and this might take a few hours. So, this processing of data and sending to MQ needs to be done on a seperate application, which cannot be run on the same server on which my application A1 is running(to avoid overloading the server).

3. My concern here is, how will I invoke this seperate(Send to MQ) application from my application A1 whenever the user would want to trigger sending data to MQ from the application A1.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Answered on the other thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Fire a trigger from an external application on database update
 
Similar Threads
Modifying XML files from Oracle
Invoke a seperate application from my Application server
Hibernate insert fails due to generate key failure
Calling Java Application from Database trigger
Working with multiple database Tables