This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes how to automatically detect a row insertion in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to automatically detect a row insertion in database" Watch "how to automatically detect a row insertion in database" New topic
Author

how to automatically detect a row insertion in database

utsav gupta
Ranch Hand

Joined: Mar 19, 2009
Posts: 57
Hi

I want to an application be triggered as soon as a row is inserted in a database. I wwould like to have it happen on an event basis. That is as soon as a row is inserted an oject is created or a function is called. Is there a way to do it?

Thanks
utsav.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
That depends on which database you're using. Many databases have a feature called "trigger", which are stored procedures executed when certain conditions occur (like an insert in a table). Some databases allow stored procedures to be written in Java (Oracle, PostgreSQL with the PL/Java extension, Derby etc.). This wouldn't work if you wanted that object created (or method called) not in the DB but in some external application.


Ping & DNS - my free Android networking tools app
utsav gupta
Ranch Hand

Joined: Mar 19, 2009
Posts: 57
Hi

Thanks for your reply.

Is it possible to create an object that can keep a watch on a particular table in java and invoke a method when a row enters. In that way I would be able to generate a code that will common to all types of database.

However my current focus is oracle and db2.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
Yes - consult the documentation of the DB you're using about "triggers" and "stored procedures written in Java".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to automatically detect a row insertion in database
 
Similar Threads
Database entry on refreshing the browser
ResultSet Update problem with Oracle 9i using JDBC
Failed to insert a record into MSAcess
updateable and scrollable resultset for oracle driver
CMP bean and timezones