Exception
Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [\. D:\Documents\workspace-sts-3.0.0.RELEASE\groupbased\src\test\resources\stress\storedProcedures.sql]; nested exception is 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 '\. D:\Documents\workspace-sts-3.0.0.RELEASE\groupbased\src\test\resources\stress' at line 1
Java Code
template.execute("USE example_db;");
template.execute("\\. D:\\Documents\\workspace-sts-3.0.0.RELEASE\\groupbased\\src\\test\\resources\\stress\\storedProcedures.sql");
(template is a JDBCTemplate)
I can run the command fine through the mysql console, but I get this error any time I try to do it through JDBCTemplate execute. Any suggestions?
Yes. Try reading the contents of the file into a String and passing that to the template.
The javadocs say that the argument should be the actual SQL, not a file path.
http://static.springsource.org/spring/docs/3.0.6.RELEASE/api/org/springframework/jdbc/core/JdbcTemplate.html