Есть запрос:
INSERT INTO DocumentWarehouse (`Ref`, `Number`, `DateTime`)
VALUES
('4583b3b4-c53f-11e8-bca5-0025b502b04e', '102-01554356', '2018-10-01T09:00:17')
ON DUPLICATE KEY UPDATE Ref = VALUES(Ref);
DELETE FROM DocumentWarehouse_Owner WHERE "Ref" IN
("4583b3b4-c53f-11e8-bca5-0025b502b04e");
INSERT INTO DocumentWarehouse_Owner (`Ref`, `RowNumber`)
VALUES
('4583b3b4-c53f-11e8-bca5-0025b502b04e', '1.0');
Выдает ошибку в Intelij Idea:
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 'DELETE FROM DocumentWarehous_OwnerDocuments WHERE "Ref" IN
(' at line 5
В консоли выполняется нормально.Что может быть?
P.S: вот метод генерирующий часть кода на который ругается:
private String getDeleteChildRows(EntityModel entityModel, LinkedList<String> refValues) {
StringBuilder deleteChildFieldRequest = new StringBuilder();
StringBuilder deleteChildValues = new StringBuilder();
for (String value : refValues) {
deleteChildValues.append(String.format("\"%s\",\n", value));
}
deleteChildValues.setLength(deleteChildValues.length() - 2);
for (String childTableName : entityModel.getTabularSection().keySet()) {
deleteChildFieldRequest.append(String.format("DELETE FROM %s_%s WHERE \"Ref\" IN\n(%s);\n", entityModel.getName(), childTableName, deleteChildValues));
}
return deleteChildFieldRequest.toString();
}
также:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
private BasicDataSource ds;
private static String databaseUrl;
private static String user;
private static String password;
private static int dbPoolSize;
public DataSource(String databaseUrl, String user, String password, int dbPoolSize) {
DataSource.databaseUrl = databaseUrl;
DataSource.user = user;
DataSource.password = password;
DataSource.dbPoolSize = dbPoolSize;
ds = new BasicDataSource();
ds.setUsername(user);
ds.setPassword(password);
ds.setUrl(databaseUrl);
ds.setMaxIdle(dbPoolSize);
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setDefaultAutoCommit(false);
ds.setDefaultTransactionIsolation(TRANSACTION_READ_COMMITTED);
ds.addConnectionProperty("useUnicode", "yes");
ds.addConnectionProperty("characterEncoding", "utf8");
private Statement statement;
statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
statement.setFetchSize(Integer.MIN_VALUE);
public void executeRequest(String request) throws SQLException { statement.execute(request); }
"Ref"
замените на`Ref`