• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

How to know when a table has new data?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use trigger.

when you table insert a new row. your trigger send the message to you java program and to tell you.

try..
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i also agree with Yu Tao ..You can use a trigger.

But is it possible to call a Java Stored Procedure from a trigger.
[ December 20, 2004: Message edited by: srini vasan ]
 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by srini vasan:
Yes i also agree with Yu Tao ..You can use a trigger.

But is it possible to call a Java Stored Procedure from a trigger.

[ December 20, 2004: Message edited by: srini vasan ]



yes using Procedure is the best case.
 
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.

Thanks,
Jeanne
Forum Bartender
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
George Bendemann
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Jeanne Boyarsky
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
George,
Sure. Just have the trigger call the java stored procedure.

(Thanks for updating the display name)
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
George,

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).

Just another option to consider.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic