Skip to content

ScriptUtils and ScriptStatementFailedException confuse lines and statements [SPR-12752] #17349

@spring-projects-issues

Description

@spring-projects-issues

Johannes Mockenhaupt opened SPR-12752 and commented

I'm using a ResourceDatabasePopulator to initialize a DB for tests. If a SQL statements fails (and continueOnError is false) an exception like this is raised:

org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 7 of resource class path resource [sql/test-data-insert.sql]: INSERT INTO [...]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:474) ~[spring-jdbc-4.0.6.RELEASE.jar:4.0.6.RELEASE]

The issue is that the exception message is misleading. The statement in question is in line 16 (with comments and blank lines in between), which is the 7th statement. It seems the lineNumber variable doesn't refer to line numbers but rather to parsed statements.


Affects: 4.0.6

Referenced from: commits 45a80fa, 8f228d1, 291b3de, 448c99f, c0e550c, 23d52d5, 0f95c81

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions