How to implement features of a Trigger in Java Program

Hi,

I need help for implementing a Java program which acts as a trigger. The Java program should act as a listener and when some update, insert or delete happens in a database table, this Java program should be able call some other class. If anybody can help me on this, it would be greatful.

Thank you

Regards

Anoop

[348 byte] By [Anoop.Retnaa] at [2007-11-27 7:58:22]
# 1
Try to do it in the class where you are doing the update, insert or delete operation.... i.e. at the level of the application that is interacting with the database... it will be a lot easier... as soon as you do a database change, call the desired class object or something of that sort...
@@CKM@@a at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 2
For that the class should be some kind of a listener right? How can I make the class as a Database listener. Is there any API available.
Anoop.Retnaa at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 3
don't go for complexities when you find solution in simplicity... just invoke the method on the desired object(the class you wish to call) in the class where you are querying the database...
@@CKM@@a at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 4
But how the class will know when an update happened in database. It should be continuosly looking the table for update right? can u provide some kind of an algorithm for wat u suggested.Thank you
Anoop.Retnaa at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 5

> But how the class will know when an update happened

> in database. It should be continuosly looking the

> table for update right? can u provide some kind of an

> algorithm for wat u suggested.

M sorry, but you just did not get what I said... You have to invoke when you are updating the database... i.e. the class which is updating acts as the trigger...

@@CKM@@a at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 6
Actually I won't be having access to the class that is updating database. Some class will update the database, but the new class am going to write should be listening that table whether any updates are happening. Sorry if i didn't conveyed it properlyThank you
Anoop.Retnaa at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 7
can u tell us what database are u using?
@@CKM@@a at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 8
oracle 9i
Anoop.Retnaa at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 9

hmmm... ur problem is a little complicated but we can solve this... Oracle9i provides a configurable database listener at port 1521(default) i suppose... this port is open for network connections and the listener controls the database... if you don't know about this then u'll have to do a bit of homework and research... you can start with googling out and learning how to use the listener.....

cheers...

@@CKM@@a at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 10
ok, please help me on this. i have tried lot of solution for a scenario. finally i thought of writing a listener. It would be helpful for me if you can provide some outline for how to write a listener
Anoop.Retnaa at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...
# 11
See the last post of this thread: http://forum.java.sun.com/thread.jspa?forumID=31&threadID=675621
quittea at 2007-7-12 19:40:17 > top of Java-index,Java Essentials,Java Programming...