I have a java application that builds and executes an sql statement/string. When I run the application from eclipse everything works fine.
But when I run the deployed/binary application (where .sql resources are read from binaries) I get the following error:
Exception in thread "main" java.lang.RuntimeException: Error executing sql:
..
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'IF'.
I have tried to write the sql string to a file when running from eclipse and when running the deployed application. The two files are almost identical besides these small differences:
1) The working string starts with: ‘go’
2) The working string has ‘go’ before IF
Any ideas why the source version has these tags while the build version does not? I build with gradle and set the compiler to use UTF-8:
[project.compileJava, project.compileTestJava]*.options*.encoding = 'UTF-8'
This is how I read the files from the jar file:
InputStream inputStream = jarFile.getInputStream(entry);
StringWriter writer = new StringWriter();
IOUtils.copy(inputStream, writer, "UTF-8");
String string = writer.toString();
The
gois not an SQL commando, it’s a commando in eclipse. It’s used to separate query batches.To run the queries in SQL, remove the
gocommands (if possible without changing the result), or split the file on thegocommands and run one batch at a time.