This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Need help on Database TABLE Listener

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, I am krishna, I am coding or an application where I need to execute a function or get a notice on command prompt or play an alarm whenever a record is inserted into a table.

The records will be inserted into the table from another java application running somewhere on the network.

Is there any such Database Table Listener.

Thank you all in advance. Have a nice day.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "listener" part is called a database trigger. If you want a trigger to notify you when it fires, then it can call a stored procedure -- for example, Java stored procedures in Oracle.
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ernest thank you for the reply. Can you please tell me how to do the same thing with mysql database because its a free ware. I cant go for oracle.

Thank you in advance. Have a nice day.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid I don't know of any way to do it in MySQL. That doesn't mean there isn't a way, though, because this is not my area of expertise. Anybody?
 
Sheriff
Posts: 26966
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not my area of expertise either, but a bit of googling led me to the MySQL trigger FAQ page. I would guess that #13 may be the one relevant to krishna's question.
 
Saloon Keeper
Posts: 24879
174
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If free is the limiting factor, PostgreSQL might be the better choice. MySQL added stored procedures and related refinements relatively recently (MySQL 5). User-defined Functions (UDFs) have to be coded in C. In comparison, PostgreSQL has supported triggers, stored procedures and user-defined functions for a long time now, and alows a broader selection of languages to be used.

Of course, given a UDF that does an OS exec() call, you can do just about anything.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is your definition of an alarm ?

Here is my suggestion. Write a trigger that will insert an event record into a separate table. Write a small app that will poll this event table for "alarm" records and send you an email when it finds one. Sound like the solution you want ?

What exactly are you trying to achieve here. What is the context of this problem ?
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, thank you for your replies. I found some problems with triggering model. Now I decided to do it using a time based job. I ll write a java program which continuously looks into the table for new records for every 5 minutes.

But for now, I want to start from the beginning, Actually I am working on a GSM application where 2 programs will be running on the system. One for receiving the messages and storing in the database. One for sending the replies.

The first part has been finished. Note, here the 2 applications are different. I mean 2 main()'s. So whenever a record is inserted the sender application has to some how know the insertion. Which is a tedious task. So I decided to go for Time Based Job.

Thank you all for the valuable replies. Have a nice day.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:If free is the limiting factor, PostgreSQL might be the better choice. MySQL added stored procedures and related refinements relatively recently (MySQL 5). User-defined Functions (UDFs) have to be coded in C. In comparison, PostgreSQL has supported triggers, stored procedures and user-defined functions for a long time now, and alows a broader selection of languages to be used.

Of course, given a UDF that does an OS exec() call, you can do just about anything.



Yeah, I totally agree. I used to use mysql, but when I couldn't even use sequences I became concerned and moved to postgresql. LAMP should be renamed to LAPP. (sorry, didn't mean to insult any MySql people out there)
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic