wood burning stoves 2.0*
The moose likes JDBC and the fly likes automatic mail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "automatic mail" Watch "automatic mail" New topic
Author

automatic mail

Anshul kothari
Greenhorn

Joined: May 06, 2012
Posts: 1
I Want to send automatic mail or sms when any chang is made in mysql data base even no user is login at that time. means itss process run on toncat server how can i do this.???
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
How are you updating your mysql database? You need to have some kind of audit fields in your database table. Whenever a record is updated, you update the audit fields i..e updatedBy , lastUpdated. Now you can have a quartz scheduler which can poll these audit fields and based on the lastUpdatedtime can send out emails to the desired recipients.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How could any changes be made to a DB without any user being logged in?

Audit fields rely on them being used. It's not clear from Anshul's problem description that that would be the case. In fact, it's not clear at all how the DB is used. Given that, I'd say the problem description is too vague to advise on anything.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1615
    
  13

Piyush Mangal wrote:How are you updating your mysql database? You need to have some kind of audit fields in your database table. Whenever a record is updated, you update the audit fields i..e updatedBy , lastUpdated. Now you can have a quartz scheduler which can poll these audit fields and based on the lastUpdatedtime can send out emails to the desired recipients.

It's not clear what the OP really wants here, but it sounds like this is a case where DB triggers might help.

Set up a trigger on each of the relevant tables to respond to the changes you are monitoring for, and let it write an entry to a log table (or file) with the information you want to know about. Then poll this log to get the latest changes. By using triggers, you can distinguish between inserts/updates/deletions, and it means the DB takes care of responding to the initial events which may be on multiple tables, while you only have to look in one place - the log - to see what's changed. This will probably be more efficient than constantly polling your original data tables in case they've changed, especially when nothing is happening on your DB or if your data tables are large.

But be careful with your triggers e.g. don't let your triggers make changes to other tables that have their own triggers, or you'll end up cascading changes around your DB like crazy!


No more Blub for me, thank you, Vicar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: automatic mail
 
Similar Threads
automatic mail from jsp page.
Automatic Mail sending Process...
Have email notification option when replying
Using javamail how automaticmail send
doubt in automatic email classification using naive bayes algorithm