use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.
the class BatchProcedureExecutionConnectionCallback method fillProcMetaData.
private void fillProcMetaData(String procName, Connection con, StoredProcedureMetaData procMetaData) throws SQLException {
SimpleJdbcCall call = handler.getCall(procName, handler.createCallForModification(procName));
Map<String, SqlCallParameter> paramOrder = new HashMap<>();
String procNameFromDB = null;
String procSchemaFromDB = null;
StringBuilder params = new StringBuilder();
try (ResultSet rs2 = con.getMetaData().getProcedureColumns(null, null, call.getProcedureName().toLowerCase(), "%")) {
int internalCounter = 1;
while (rs2.next()) {
ProcData procData = fillProcData(rs2, internalCounter);
if (procData != null) {
++internalCounter;
paramOrder.put(procData.getColName(), new SqlCallParameter(procData.getOrdinal(), procData.getColName(), procData.getDataType()));
procNameFromDB = procData.getProcName();
procSchemaFromDB = procData.getSchemaName();
params.append("CAST (? AS ").append(procData.getDbTypeName()).append("),");
}
}
if (params.length() > 0) {
params.deleteCharAt(params.length() - 1);
}
} catch (SQLException e) {
log.error("Can't get procedure '{}' meta data: {}", procName, e.getMessage());
log.debug("Exception", e);
}
procMetaData.setSqlCommand(handler.getDialect().createSqlCallCommand(procSchemaFromDB, procNameFromDB, params.toString()));
procMetaData.setDbName(procNameFromDB);
procMetaData.setParamatersMetaData(paramOrder);
procMetaData.setSchemaName(procSchemaFromDB);
}
use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.
the class SimpleJdbcCallsHandler method getCall.
protected <T> SimpleJdbcCall getCall(String procedureName, CallCreator callCreator, RowMapper<T> mapper) {
SimpleJdbcCall call = callsMap.get(procedureName);
if (call == null) {
call = callCreator.createCall();
call.compile();
callsMap.putIfAbsent(procedureName, call);
} else if (mapper != null) {
call.returningResultSet(RETURN_VALUE_PARAMETER, mapper);
}
return call;
}
use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.
the class VmDeviceDaoImpl method isMemBalloonEnabled.
@Override
public boolean isMemBalloonEnabled(Guid vmId) {
MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_id", vmId);
Map<String, Object> dbResults = new SimpleJdbcCall(getJdbcTemplate()).withFunctionName("isMemBalloonEnabled").execute(parameterSource);
String resultKey = getDialect().getFunctionReturnKey();
return (Boolean) dbResults.getOrDefault(resultKey, false);
}
use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.
the class QuotaDaoImpl method isQuotaInUse.
@Override
public boolean isQuotaInUse(Quota quota) {
MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("quota_id", quota.getId());
Map<String, Object> dbResults = new SimpleJdbcCall(getJdbcTemplate()).withFunctionName("IsQuotaInUse").execute(parameterSource);
String resultKey = getDialect().getFunctionReturnKey();
return dbResults.get(resultKey) != null && (Boolean) dbResults.get(resultKey);
}
use of org.springframework.jdbc.core.simple.SimpleJdbcCall in project ovirt-engine by oVirt.
the class DbUserDaoImpl method updateLastAdminCheckStatus.
@Override
public void updateLastAdminCheckStatus(Guid... userIds) {
MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("userIds", StringUtils.join(userIds, ","));
new SimpleJdbcCall(getJdbcTemplate()).withProcedureName("UpdateLastAdminCheckStatus").execute(parameterSource);
}
Aggregations