Java run by MySQL trigger

后端 未结 3 1866
太阳男子
太阳男子 2021-01-05 07:40

I am trying to create some MySQL code that will invoke a Java program from a trigger.

Here is what I have so far:

CREATE TRIGGER trig_name after inse         


        
3条回答
  •  甜味超标
    2021-01-05 07:51

    Calling a java method from an SQL database isn't a standard feature. The Informix DB can call a shell script from a stored procedure, but I don't know of a feature like this in MySQL (I'm not an expert on mysql).

    The closest thing that works with all databases would be to have a thread and periodically poll the database for new records.

    SELECT * FROM studentinfo WHERE id > last_seen_id
    

    Or you could use a timestamp:

    SELECT * FROM studentinfo WHERE create_date >= last_seen_create_date
    

    In this case you would have to filter duplicated rows which have already loaded from the previous run.

提交回复
热议问题