Good. Most of the problems solved.
You must be aware of a startup servlet.
Register a startup servlet in the web.xml. In this, start a thread. Check the current date in this thread. Query the DB and compare if its -45 from the DB date, if it is, then do the mail sending part. If it is not...