This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I have a requirement whenever a request is raised which comes as a new row in the database, i need to send a SMS and an email to the users. I wrote a trigger on my input table to send the SMS which is just a insert query into the SMS table. Now i also have to send an email. Please help me out how can i send an email from trigger. Is there is any way of invoking a Java Program from a Trigger?
If it doesn't some database include mechanisms to make calls to the OS shell. Also some database support the sending for notifications without the need to write a Java program to do it. Which database are you using?
If your database supports none of these things you could poll the table from your Java program. OK there will be a delay, but email is asynchronous so a delay is acceptable.
Another solution would be to insert the message that you want to send with the all the necessary details and make a java scheduler that checks the content of this table from time to time and handles every record with the way it should.
This solution is more universal since not all databases support java.
Joined: Aug 12, 2009
Anyhow i tried using utl_smtp package, but i am getting the runtime error while using open_connection function.
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at "SYS.UTL_SMTP", line 21
ORA-06512: at "SYS.UTL_SMTP", line 97
ORA-06512: at "SYS.UTL_SMTP", line 139
I am able to send email successfully with the same server from java. Please help me out.