1

In my app I creating tables with Hibernate annotations, but after this I want to create mysql script to generate raports:

In my resources folder I created data.sql :

DROP EVENT IF EXISTS daily_report;
DELIMITER $$
CREATE EVENT daily_report
    ON SCHEDULE EVERY 1 DAY STARTS '2018-01-01'
    ON COMPLETION PRESERVE
    DO BEGIN
INSERT INTO daily_report(day_of_report,http_errors,other_errors) VALUES(
    current_date(),
    (select count(*) from error where date(save_date)=current_date() and name="HttpError"),
    (select count(*) from error where date(save_date)=current_date() and name not in("unknown","HttpError")
));
END $$
DELIMITER ;
SET GLOBAL event_scheduler = ON;

All looks good, because when I run:

SELECT @@global.event_scheduler;

It shows that is ON, but after running:

show events

It shows no events :( data.sql script is working because when I run him directly in mysql it works - command show events showing that this daily_report scheduled event is working.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
Adam
  • 151
  • 1
  • 2
  • 14
  • according to this question: https://stackoverflow.com/questions/39581175/running-scripts-in-a-sprint-boot-web-application I changed file to import.sql and it still doesnt work :( – Adam Aug 14 '18 at 13:54
  • You may find it helpful for troubleshooting to get your event to run every five minutes; then when it works switch to once day. – O. Jones Aug 14 '18 at 14:02
  • Have you confirmed that account you use for Hibernate db session has EVENT privilege? – vhu Aug 14 '18 at 19:06

0 Answers0