0

I am trying to initialize stored procedure and I get this error below. When I execute the procedure manually everything is fine. I tried adding DELIMITER // as suggested here and here but it didn't work. Any advice is appreciated.

Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.27.jar:8.0.27] at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.27.jar:8.0.27] at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:768) ~[mysql-connector-java-8.0.27.jar:8.0.27] at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:653) ~[mysql-connector-java-8.0.27.jar:8.0.27] at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na] at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na] at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:261) ~[spring-jdbc-5.3.12.jar:5.3.12] ... 28 common frames omitted

The procedure:

CREATE PROCEDURE usp_move_cancelled_booking(IN booking_id_param bigint)
BEGIN
INSERT INTO booking_history
(booking_time, check_in, check_out, comments, email,
   first_name)
SELECT b.booking_time,
       b.check_in,
       b.check_out,
       b.comments,
       b.email,
       b.first_name
FROM bookings as b
JOIN properties as p on b.property_id = p.id
WHERE b.id = booking_id_param;
END;
sjs
  • 35
  • 1
  • 6
  • You don't need `DELIMITER` if you're doing this from Java. That's only needed in interactive clients. – Barmar May 05 '22 at 18:13
  • It doesn't work without the delimiter either. I have updated my post with the exception I get without the delimiter. – sjs May 05 '22 at 18:23
  • Since you are using `executeSqlScript()` this looks like the same issue as in this question: https://stackoverflow.com/q/35911065/20860 – Bill Karwin May 05 '22 at 19:19

0 Answers0