use of com.wplatform.ddal.command.expression.ParameterInterface in project jdbc-shards by wplatform.
the class JdbcPreparedStatement method setParameter.
// =============================================================
private void setParameter(int parameterIndex, Value value) {
checkClosed();
parameterIndex--;
ArrayList<? extends ParameterInterface> parameters = command.getParameters();
if (parameterIndex < 0 || parameterIndex >= parameters.size()) {
throw DbException.getInvalidValueException("parameterIndex", parameterIndex + 1);
}
ParameterInterface param = parameters.get(parameterIndex);
// can only delete old temp files if they are not in the batch
param.setValue(value, batchParameters == null);
}
use of com.wplatform.ddal.command.expression.ParameterInterface in project jdbc-shards by wplatform.
the class JdbcPreparedStatement method addBatch.
/**
* Adds the current settings to the batch.
*/
@Override
public void addBatch() throws SQLException {
try {
debugCodeCall("addBatch");
checkClosedForWrite();
try {
ArrayList<? extends ParameterInterface> parameters = command.getParameters();
int size = parameters.size();
Value[] set = new Value[size];
for (int i = 0; i < size; i++) {
ParameterInterface param = parameters.get(i);
Value value = param.getParamValue();
set[i] = value;
}
if (batchParameters == null) {
batchParameters = New.arrayList();
}
batchParameters.add(set);
} finally {
afterWriting();
}
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of com.wplatform.ddal.command.expression.ParameterInterface in project jdbc-shards by wplatform.
the class Trace method formatParams.
/**
* Format the parameter list.
*
* @param parameters the parameter list
* @return the formatted text
*/
public static String formatParams(ArrayList<? extends ParameterInterface> parameters) {
if (parameters.size() == 0) {
return "";
}
StatementBuilder buff = new StatementBuilder();
int i = 0;
boolean params = false;
for (ParameterInterface p : parameters) {
if (p.isValueSet()) {
if (!params) {
buff.append(" {");
params = true;
}
buff.appendExceptFirst(", ");
Value v = p.getParamValue();
buff.append(++i).append(": ").append(v.getTraceSQL());
}
}
if (params) {
buff.append('}');
}
return buff.toString();
}
Aggregations