Spring Boot Database initialization MySQLException for Trigger

前端 未结 2 2094
别跟我提以往
别跟我提以往 2021-01-19 12:23

I am using Spring Boot Database initialization using Spring JDBC with schema.sql file.I am using MYSQL

If I have simple table creation in schema.sql as follows it wo

2条回答
  •  死守一世寂寞
    2021-01-19 12:49

    My issue was resolved when I have added spring.datasource.separator=^; in application.properties and every line out side the procedure/trigger should be terminated with ^; Example as follows:

    DROP TRIGGER IF EXISTS Persons_log_update ^; 
    
    CREATE TRIGGER Persons_log_update 
        BEFORE UPDATE ON Persons
        FOR EACH ROW 
    BEGIN
    
        INSERT INTO Personshistory(PersonID,LastName,FirstName,Address,City)
        values(OLD.PersonID,OLD.LastName,OLD.FirstName,OLD.Address,OLD.City);
    
    END ^;
    

提交回复
热议问题