aspose file tools*
The moose likes JDBC and the fly likes How to watch when database table row has changed using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to watch when database table row has changed using java" Watch "How to watch when database table row has changed using java" New topic
Author

How to watch when database table row has changed using java

suhasini dharmisetty
Greenhorn

Joined: Oct 07, 2008
Posts: 19
Hi,
My requirement is when database table row has changed i keep track that record through java..If any body knows please help me.
thanks in advance.
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

You will have to write a Job in Java to check the table.

This job would select this row every time (or if the database offers a last modified date you could select for it also).

You can use Quartz to schedule your jobs.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Dwarka Damodaran
Greenhorn

Joined: Nov 10, 2011
Posts: 7
If you are using one of the matured Databases, then you should have the option of database triggers. You can configure a trigger for the expected table and let the trigger communicate the change to your java program. In this way you are using the inherent feature supported by the database (Which is obviously performance effective) and also reducing the load on the application or the web server.

For how to use java in Oracle triggers see the following link

http://www.cs.umbc.edu/portal/help/oracle8/java.815/a64686/04_call2.htm

Hope this helps.

Thanks and Regards,
Dwarka
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

Dwarka Damodaran wrote:...You can configure a trigger for the expected table and let the trigger communicate the change to your java program. ...

If I'm not mistaken, the page you link to shows how to call Java Stored Procedure on Oracle. It still takes some (or lots of) work to remotely call Java on a webserver from that, for example.

However, starting at version 10g, Oracle offers a Database Change Notification functionality for exactly this purpose. I should say we had some troubles getting it to work and currently do not use it, but it might be caused by the fact that our tables were modified quite often and by "big" transactions. We'll probably retry when we'll finish moving to 11g.

Oracle 11g offers lots of new features, eg. the client result cache (if the answer to a query is not modified, the client does not go into database, but uses the cached result), which allows for effective polling mechanisms to be employed. Might be easier than battling with Database Change Notification. I'm not sure whether an JDBC OCI client would not be needed for this, though.

But your main point is true, Oracle has tools specifically designed for this and other databases might offer similar features. It is definitely good idea to check them out.
Vikram P Deshmukh
Greenhorn

Joined: Apr 25, 2013
Posts: 1

please go through below links ,because i implemented in my project it's work fine , hope this will fulfill your requirement.

http://theblasfrompas.blogspot.in/2010/02/using-database-change-notification-dcn.html

http://docs.oracle.com/cd/E11882_01/java.112/e16548/dbchgnf.htm

http://appcrawler.com/wordpress/2012/08/28/jdbc-and-oracle-database-change-notification/

http://jirawong.wordpress.com/2013/03/27/oracle-database-change-notification-jdbc-style-example/


many more example are just search "DCN JDBC example"

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to watch when database table row has changed using java