Skip to content

ScriptUtils fails to split statements of a SQL script [SPR-16927] #21466

@spring-projects-issues

Description

@spring-projects-issues

Steffen Harbich opened SPR-16927 and commented

Consider the following script (quartz tables_mysql_innodb.sql):

#
# In your Quartz properties file, you'll need to set
# org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#
#
# By: Ron Cordell - roncordell
# I didn't see this anywhere, so I thought I'd post it here. This is the script from Quartz to create the tables in a MySQL database, modified to use INNODB instead of MYISAM.

DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
...

It is executed using QuartzAutoConfiguration's QuartzDataSourceInitializer for mysql. The ScriptUtils class will finally parse this script as 2 statements in line 464 (https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java#L464) which is wrong I think. Executing those statements results in a syntax exception because only one statement can be executed at a time:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS; DROP TABLE IF EXISTS QRTZ_SCHEDUL' at line 9

If I remove the comments from the script then everything works fine as expected. I suspect that parsing of apostrophe in comment doesn't work as intended.


Affects: 5.0.6

Reference URL: https://stackoverflow.com/questions/50793308

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions