Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

automatic mail

 
Anshul kothari
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2803
41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2407
32
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic