0

How can I chain multiple sql statements into one sql? Because I want to externalize a bunch of sql statements that should be executed with one jdbctemplate call. So I'm trying to chain them into one update statement:

jdbcTemplate.update("DROP TABLE IF EXISTS mytable; CREATE TABLE mytable like source_table;");

Result:

Caused by: java.sql.SQLException: 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 'CREATE TABLE mytable like source_table;' at line 1
membersound
  • 81,582
  • 193
  • 585
  • 1,120
  • See https://stackoverflow.com/questions/18515471/can-i-execute-multiple-queries-separated-by-semicolon-with-mysql-connector-j – Ori Marko Mar 07 '19 at 12:40
  • see https://stackoverflow.com/questions/9565481/how-to-do-multiple-inserts-in-database-using-spring-jdbc-template-batch – Akash Shah Mar 07 '19 at 12:48

0 Answers0