• Post Reply Bookmark Topic Watch Topic
  • New Topic

fetch the value,check for condition and send email notification  RSS feed

 
Foni kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Experts,

I am currently working on a java code where I need to check the values against an attribute called as Expiry date for a webpage . If the expiry date is of today then I need to send an automatic email notification to the owner of the web page with a message "Your page is getting expired today".

Could anyone help me out in figuring out this approach. Please provide any sample code snippets or links with this reference ,it will be real helpful.Appreciate for all your help in this regard.

Note : Both these attributes are present in the database table say db_web

Thanks and Regards,
Deb
 
Prabaharan Gopalan
Ranch Hand
Posts: 66
Java Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you expect us to provide a design so that you can use it at work? Before we could do that, please tell us what approaches have you thought of for this problem and why would you not use one of them?
 
Foni kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prabaharan Gopalan wrote:Do you expect us to provide a design so that you can use it at work? Before we could do that, please tell us what approaches have you thought of for this problem and why would you not use one of them?



Hi Prabaharan ,

My approach is to get the values in a rs and iterate the condition though if and else and then send mail to the owner using send mail api. Well I understand this forum is to help each other for better learning. I havent asked you to work on the codes but i asked you if you have any similar reference materials or links do provide just as a help or get some better ideas apart of the ones I have in my mind currently,dont take it otherwise,it sounds bad .

It is not for any work purpose i have put that question above. It is just for my learning I have given a hypothetical condition. If you don't want to put any of your ideas please let others put their ideas. Lets make this forum more effective and fruitful.

Lets propose ideas and not assume and oppose someone who puts a question! It is all for our learning,I hope you understand.

Thanks!
 
Prabaharan Gopalan
Ranch Hand
Posts: 66
Java Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it's our intention to help in whatever we can. I was just reflecting this: ShowSomeEffort . (which I haven't seen in the OP).

As to your question, the resultset would work good but I'd rather have the if-else in the SQL query itself. (Like SELECT ... WHERE exp_date = TODAY'S_DATE . That way, we only get one row and avoid the overhead of iterating through the entire table every time and the if-else as well) I understand that you want to execute that logic on a daily basis. Which sounds to me like an ideal candidate for Quartz (or some scheduler library). Is it going to run on a web application or a stand alone java app? In case of the former, you might want to look at the datasource provided by the container to manage connections and still have the resultset code that you now have. And you can start the scheduled job via load-on-startup or during context initialization.

If you are aware of Spring, then Spring JDBC will handle some of the boiler plate code for you. But end of the day, it's going to be a JDBC connection and a result set, no matter how abstract it gets.

HTH.
 
Foni kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prabaharan Gopalan wrote:And it's our intention to help in whatever we can. I was just reflecting this: ShowSomeEffort . (which I haven't seen in the OP).

As to your question, the resultset would work good but I'd rather have the if-else in the SQL query itself. (Like SELECT ... WHERE exp_date = TODAY'S_DATE . That way, we only get one row and avoid the overhead of iterating through the entire table every time and the if-else as well) I understand that you want to execute that logic on a daily basis. Which sounds to me like an ideal candidate for Quartz (or some scheduler library). Is it going to run on a web application or a stand alone java app? In case of the former, you might want to look at the datasource provided by the container to manage connections and still have the resultset code that you now have. And you can start the scheduled job via load-on-startup or during context initialization.

If you are aware of Spring, then Spring JDBC will handle some of the boiler plate code for you. But end of the day, it's going to be a JDBC connection and a result set, no matter how abstract it gets.

HTH.


Thankyou Prabhaharan ,that was helpful..Now I have added the modifications in the query itself.Only thing I am thinking is to send email to the owner based on the condition. I am creating a report say and attaching it to the mail and sending it to the owner when the document is expired. I suppose we can use some conditions for sendmail method to execute this automatically based on the conditions
 
Prabaharan Gopalan
Ranch Hand
Posts: 66
Java Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose we can use some conditions for sendmail method to execute this automatically based on the conditions


Which sendmail are we talking about here? I wasn't aware of any in-built automatic mail handling in Java.
 
Foni kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prabaharan Gopalan wrote:
I suppose we can use some conditions for sendmail method to execute this automatically based on the conditions


Which sendmail are we talking about here? I wasn't aware of any in-built automatic mail handling in Java.


:-) sorry for the confusion I created above, sendmail is my own method , I am making use of MIME protocol to make this automation of email services ... I actually done with my code work only i wanted to know the port number that I need to use..Thanks for being so kind and all help so far
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!