I use com.sybase.jdbc42.jdbc.SybDriver
to connect to sybase.
I get
SQL Anywhere Error -188: Not enough values for host variables
when I execute multiple statements like this :
delete from CHARGING_PLAN2APPLICATIONS where CHARGING_P LAN_ID=?;update CHARGING_PLAN set NAME= ? ,ADMIN =?,LAST_CHANGE= current utc timestamp where ID=?;
It could happen with different statements: delete + update or insert + insert. With remote debug I checked that I pass all variabless required for statement. In pseudocode it looks like that:
public void executeMultipleStatementQuery(List<TransactionData> queries) throws SQLException {
Connection conn = getConnection();
StringBuilder fullStatement = new StringBuilder(500);
List<Object> totalParams = new ArrayList<>();
// save all queries to one string and separate them with ";"
for (TransactionData query : queries) {
fullStatement.append(query.getSqlStatement());
fullStatement.append(";");
Collections.addAll(totalParams, query.getParams());
}
PreparedStatement stm = conn.prepareStatement(fullStatement.substring(0, fullStatement.length() - 1));
// save all parameters to PreparedStatement
for (Object param : totalParams) {
if (param instanceof NullValue) {
stm.setNull(i, ((NullValue) param).getType());
} else {
stm.setObject(i, param);
}
i++;
}
}
But get SQL error.
When I sent each statement separately - it works...
What could be a root cause of such error?