Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6071013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:59:56+00:00 2026-05-23T09:59:56+00:00

Could someone please guide me into the right direction for this: I wan to

  • 0

Could someone please guide me into the right direction for this:

I wan to have an asynchronous function in my Java program that when called, it continuously monitors changes of some table in the DB. And when a change occurs, it returns some event. But it keeps doing this, as long as the application is running.

Any help would be great… thnx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:59:56+00:00Added an answer on May 23, 2026 at 9:59 am
    • You can use a thread in function which can monitor the changes in some table.
    • In thread write code to access the database related queries.

      You can make use of Quartz – an open source job scheduling service.

      http://www.quartz-scheduler.org/

    Source :Trigger example with Java method getting invoked whenever triiger is called

    Trigger Example

    This example creates a trigger. It follows the development model described in “Model 2: Using the Attached Stored Procedure Development Model”. For an example of creating triggers using the load and publish model, see “Trigger Arguments Example”. In the example, you first create a table and a Java class. Then you attach the class to the table. And finally, you create and fire the trigger.

    The SalaryTrigger class contains the check_sal_raise method. The method prints a message if an employee gets a salary raise of more than ten percent. The trigger fires the method before updating a salary in the EMP table.

    Since check_sal_raise writes a message to standard output, you should use the DOS-based version of SQL*Plus to issue the SQL commands in the example. Start SQL*Plus in a DOS Command Prompt window by typing:

    plus80 username/password@connect_string

    connect_string is ODBC:data_source_name. For example, to connect to the default database as user SYSTEM, at the DOS prompt type:

    plus80 system/pw@odbc:polite

    At the SQL*Plus command line, create and populate the EMP table as follows:

    CREATE TABLE EMP(E# int, name char(10), salary real,

    Constraint E#_PK primary key (E#));

    INSERT INTO EMP VALUES (123,’Smith’,60000);

    INSERT INTO EMP VALUES (234,’Jones’,50000);

    Place the following class in SalaryTrigger.java:

     class SalaryTrigger {
    
          private int eno;
    
          public SalaryTrigger(int enum) {
    
          eno = enum;
    
          }
    
         public void check_sal_raise(float old_sal,float new_sal)
         {
            if (((new_sal - old_sal)/old_sal) > .10)
            {
               // raise too high  do something here
               System.out.println("Raise too high for employee " + eno);
            }
         }
       }
    

    The SalaryTrigger class constructor takes an integer, which it assigns to attribute eno (the employee number). An instance of SalaryTrigger is created for each row (that is, for each employee) in the table EMP.

    The check_sal_raise method is a non-static method. To execute, it must be called by an object of its class. Whenever the salary column of a row in EMP is modified, an instance of SalaryTrigger corresponding to that row is created (if it does not already exist) with the employee number (E#) as the argument to the constructor. The trigger then calls the check_sal_raise method.

    After creating the Java class, you attach it to the table, as follows:

    ALTER TABLE EMP ATTACH JAVA SOURCE “SalaryTrigger” IN ‘.’

    WITH CONSTRUCTOR ARGS(E#);

    This statement directs Oracle Lite to compile the Java source file SalaryTrigger.java found in the current directory, and attach the resulting class to the EMP table. The statement also specifies that, when instantiating the class, Oracle Lite should use the constructor that takes as an argument the value in the E# column.

    After attaching the class to the table, create the trigger as follows:

    CREATE TRIGGER CHECK_RAISE BEFORE UPDATE OF SALARY ON EMP FOR EACH ROW

    “check_sal_raise”(old.salary, new.salary);

    /

    This statement creates a trigger called check_raise, which fires the check_sal_raise method before any update to the salary column of any row in EMP. Oracle Lite passes the old value and the new value of the salary column as arguments to the method.

    In the example, a row-level trigger fires a row-level procedure (a non-static method). A row-level trigger can also fire table-level procedures (static methods). However, because statement-level triggers are fired once for an entire statement and a statement may affect multiple rows, a statement-level trigger can only fire a table-level procedure.

    The following command updates the salary and fires the trigger:

    UPDATE EMP SET SALARY = SALARY + 6100 WHERE E# = 123;

    This produces the following output:

    Raise too high for employee 123

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please could someone help diagnose this tiny problem that shouldn't be one - trying
Can someone guide me in the right direction on how to implement and at
I'm trying to transform this xml. However I'm having formatting issues. Could someone please
Could someone please guide me on the correct format string to display a time
Could someone please point me to a good beginner guide on safely running SQL
Could someone please demystify interfaces for me or point me to some good examples?
Could someone please tell me which objects types can be tested using Regular Expressions
Could someone please explain the best way to connect to an Interbase 7.1 database
Could someone please point me toward a cleaner method to generate a random enum
Could someone please explain? I couldn't find anything on the internet, everything talks about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.