1
我试图执行包含存储过程的文件。我使用下面的代码来做到这一点,但我不断收到一个错误,说我的语法错了。它似乎不喜欢涉及DELIMITER的第一行。任何人有任何建议?Java Spring - 从文件执行MySQL查询
的Java
final ResourceDatabasePopulator rdp = new ResourceDatabasePopulator();
rdp.addScript(new ClassPathResource("storedProcedures.sql"));
try {
rdp.populate(dataSource.getConnection());
} catch (SQLException e) {
e.printStackTrace();
}
异常
Caused by: 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 'DELIMITER // DROP PROCEDURE IF EXISTS `GetEvents`// CREATE PROCEDURE `GetEvents`' at line 1
我投了这个问题,因为我不知道在Spring JDBC中有ResourceDatabasePopulator这样的事情。现在我知道了。谢谢! –
有没有解决这个问题?我遇到了同样的问题,sql是从mysqldump生成的,所以我认为它格式正确。 – AgentRegEdit