• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Monitoring database table for changes

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am currently beginning to work with EJBs. I am trying to decide if and what flavor bean (or other JavaEE technology) I should use for the following problem:

I need to look for changes to a database table every x seconds. Of course, if a change is detected, I need to then do something based on that change. Then
I would need to change another field in the database so that when I come back to it in x seconds, I do not detect the same change multiple times.

What would be the best approach for dealing with this problem?

Thanks in advance for any help,
B Porter
 
author & internet detective
Posts: 41860
908
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
I can think of two approaches:
1) Add a last updated field to each column and check for changes since your last visit.
2) Add a trigger to write the fact that a column has changed elsewhere.

With either approach, you'll want a Timer at the JEE end to regularly query for changes.
 
B Porter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

I do have a column/field that I write to after I detect a change to prevent duplicate data grabs.

The problem is that I don't know what type of bean I should be using to do this kind of work if I
wanted to use EJBs to do this portion of the work.

So, what is the best EJB construct to do this? Which flavor of EJB should I be grabbing the data with
and for detecting the change (I am just using a timer and a jdbc call every 10 seconds right now).

Thanks Again for your time,
B Porter
 
B Porter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope the following is an appropriate plan

So I am going to try the following:

Set up a stateless Session bean with a timer function to query an input table for new rows.

New row(s) show up
Make a call to an Entity Bean that will input the new data in its appropriate table

Have a separate stateless Session bean that is called by first bean to do other business logic on
the data that is now in table.

My question - does this seem like a scalable/smart way of doing this?

Thanks for any suggestions,
B Porter
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
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

B Porter wrote:New row(s) show up
Make a call to an Entity Bean that will input the new data in its appropriate table


I don't follow this. The new row is in the table, no? Do you mean another table?

B Porter wrote:Have a separate stateless Session bean that is called by first bean to do other business logic on
the data that is now in table.


This part seems good.
 
B Porter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the confusion -
You have a dump off table for the listener bean

Then you have another table for the Entity bean


Thanks for your patience,
B Porter
 
reply
    Bookmark Topic Watch Topic
  • New Topic