executeSqlScript use only one Statement to execute sql, so the getWarnings of Statement will contains pre warning

Ps: Maybe creating new Statement for every sql is better

Comment From: sbrannen

Hi @lfz757077613,

Thanks for submitting your first pull request for the Spring Framework.

According to the Javadoc for java.sql.Statement.getWarnings():

The warning chain is automatically cleared each time a statement is (re)executed.

Do you have a particular use case you can share with us where the warning chain does not get properly cleared automatically between execute() invocations in ScriptUtils?

Comment From: lfz757077613

I see "The warning chain is automatically cleared each time a statement is (re)executed." in doc. Even through I use hikari, but it call StatementImpl directly. I guess StatementImpl of mysql driver has a bug or the JavaDoc is wrong Spring Clear Statement warnings in ScriptUtils.executeSqlScript()

demo.zip

Comment From: snicoll

StatementImpl of mysql driver has a bug

That's my understanding yes. I haven't found a bug or something on the forum that talks about this. Can you please report the issue to the MySQL driver? Their contributing page provides link to their issue tracker and forum.

Comment From: lfz757077613

I have reported it to mysql. Thanks for reply https://bugs.mysql.com/bug.php?id=112195

Comment From: lfz757077613

I have reported it to mysql. Thanks for reply https://bugs.mysql.com/bug.php?id=112195

https://dev.mysql.com/doc/relnotes/connector-j/en/news-8-3-0.html mysql-connector-j 8.3.0 fix it 😁

Comment From: bclozel

  • See spring-projects/spring-boot#39081