0

I have a MySQL database (that I'll soon be moving over to MS SQL Server 2008/2012) which is accessed from a Java program I've written. Let's call this first program the "Display Program." Another Java program, which we'll call the "Updater Program," will be periodically adding data to the database. Currently, I have the Display Program on a timer that retrieves data from the database and updates its display every thirty seconds with that data. Is there any way to have the database "notify" that Display Program any time that data has been added to it, so I won't have to use a timer?

These two Java programs will be running on different computers on the network, so I don't see how to have a listener on the Display Program that the Updater Program can trigger, unless I find some way to do it through the network. (Which sounds like a whole lot of trouble.) Also, the Display Program keeps an open connection with the database, so perhaps the database can "see" that connection and somehow ping the Display Program on the other end of it to update itself?

If this isn't possible or it turns out to be extremely involved and difficult, just let me know and I'll stick with the 30-second-polling method that I'm currently using.

Sturm
  • 689
  • 2
  • 23
  • 52
  • 1
    I believe Oracle has a way to execute java code. Perhaps stored procedures can actually make networked calls, I don't know. But, if you do use these features they'll probably be database specific and make your app tied to the database. Since you're already trying to move from one DB to another, it may be a bad idea to go this route. – Daniel Kaplan Aug 05 '14 at 17:49
  • Here's a way to call a rest api within mysql: http://open-bi.blogspot.com/2012/11/call-restful-web-services-from-mysql.html – Daniel Kaplan Aug 05 '14 at 17:51
  • 1
    Similar Topic here: http://stackoverflow.com/questions/12618915/how-to-implement-a-db-listener-in-java – Mike Aug 05 '14 at 17:54
  • MS Sql has their own notification services so you don't have to poll. Last I knew the JDBC driver did not support this directly, put you can do notifications via HTTP and other methods. Using notification services works great in a .Net development environment, but it will be more painful under Java as it will be more complicated and harder to get help. Clearly not a portable solution, but it will be the most efficient for a SQL server enviroment. – Gary Walker Aug 05 '14 at 18:53

0 Answers0