Hello,

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

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.

commented: I did not know that +4

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

Thanks

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.