I don't know if I am posting this in the right section, I have a Java Database application(mysql). I have used netbeans to develop it. I have one table product_tbl which stores the stock level. I want to send an email notification to a specific email when the stock reaches '0'.

My question is do you have any idea how I can integrate that?
I thought about PHP but I am not sure if it is the right thing to use...

Thank you

3 Years
Discussion Span
Last Post by london-G

You could do it in java, however php would probably be easier.

Here is how you can send an email using php: http://php.net/manual/en/function.mail.php

with java you would have to use the JavaMail API: http://www.oracle.com/technetwork/java/javamail/index.html

In both cases what you want to do is run through your database using the primary key as your indexing and then checing if the stock is 0 or at a low number depending on your wishes. Then probably the best way to do it is to add the low items to a string and then send the whole string in an email.

PHP has the built in ways of traversing a database, bowever with java you will want to take a look at JDBC: http://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html

Hope this helps you achieve your goal.


you might well be able to send email directly from your database from a trigger on the table that you're monitoring.

Votes + Comments
I did not know that

jwenting, what do you mean by sending an email direclty from the database?


PS. I have looked at PHP and think that I am still a beginner at PHP so might consider doing it with JAVA..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.