I want to execute all sql-scripts in one folder via Java. It does not work because earlier it created a new schema (named like the username) and did not take the one written in the sql script. And now i get 44x the Exception showed below. Connection is working. Oh and im using a DB2.
I have tried the following approach:
public void sqlScripts() throws IOException, SQLException {
File folder = new File("E:/maProject/sql");
File[] listOfFiles = folder.listFiles();
for (File file : listOfFiles) {
BufferedReader reader = null;
Statement statement = null;
try {
statement = con.createStatement();
reader = new BufferedReader(new FileReader(file));
statement.execute(String.valueOf(file));
} catch (Exception e) {
e.printStackTrace();
}
}
}
This is the Exception i get 44x:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-7, SQLSTATE=42601, SQLERRMC=\;E:, DRIVER=4.26.14
What am I doing wrong?
Thanks in advance