How can I know when a specific table has gotten a new row inserted into it? I want to my java program to maintain an open connection to Oracle all day and kick off jobs based upon the fact that a certain table has gotten a new row added to it. Any ideas?
"RussianFriend RussianFriend", We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Yes Russian, I think Tao is absolutely right. But my concern here is why do u wish to keep a connection from Java open ? When u write a trigger for it u can just forget about the connection(I mean the Java part). Oracle is good/capable enough to handle it from there.
Joined: Dec 19, 2004
Everyone says to use a trigger. But I have preexisting java code that does a lot of file i/o.....can this be done in a java stored procedure? Russian_Friend (George Bendemann)
author & internet detective
If your requirements can handle a short delay between data appearing and your program processing it, you could simply poll the database from your application at a short, regular interval (every minute, every thirty seconds, whatever).
I tend to favor letting the database handle data storage and querying, period. If you have a lot of records to process, polling would allow you to run multiple applications simultaneously or take advantage of multithreading. And if you ever change the database or requirements, you won't be stuck rewriting the stored procedure again (true, not very likely).
I am too designing the same i.e. poll on the table. I will have my program run as a windows service but just curious is it ok to keep the database connection open forever. As I am planning to just use one Database connection for all my updates selected inserts etc. and if no records to be processed the programs sleep for sometime and then again checks the table for new records. So I don't opne,close the connection and keep it open as long as the service is running. Any feedbacks on if it's ok to have the database connection open all the time and how to make sure that dbconnection object still valid.
MB<br />Sun Certified Programmer for Java2 Platform