I have a small query regarding the Spring boot logic of calling the sql files. I know that the schema sql files are called automatically if they are kept inside the resource directory of the spring boot app project. But i would like to call them from a different directory. I have written the below code to try and achieve that but fails with below error message.
Code :
public void executeSqlScript()throws SQLException{
Connection connection = dataSource.getConnection();
connection.setAutoCommit(false);
ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("C:\\react-file-upload-master\\createConfigurationTableAndData.sql")));
connection.commit();
}
Error Message : java.io.FileNotFoundException: class path resource [C:/react-file-upload-master/createConfigurationTableAndData.sql] cannot be opened because it does not exist.
Its is not reading my directory. Would be greatfull if you could educate me on the same. Thank you.