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