protected CFInternetURLProtocolBuff unpackURLProtocolResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackURLProtocolResultSetToBuff"; int idxcol = 1; CFInternetURLProtocolBuff buff = schema.getFactoryURLProtocol().newBuff(); { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFBamDb2LUWSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFBamDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredURLProtocolId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; buff.setRequiredIsSecure(("Y".equals(resultSet.getString(idxcol)) ? true : false)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
public void createURLProtocol( CFSecurityAuthorization Authorization, CFInternetURLProtocolBuff Buff) { final String S_ProcName = "createURLProtocol"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory() .newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { short URLProtocolId = Buff.getRequiredURLProtocolId(); String Name = Buff.getRequiredName(); String Description = Buff.getRequiredDescription(); boolean IsSecure = Buff.getRequiredIsSecure(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_create_urlproto( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong( argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString( argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString( argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong( argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong( argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "UPRT"); stmtCreateByPKey.setShort(argIdx++, URLProtocolId); stmtCreateByPKey.setString(argIdx++, Name); stmtCreateByPKey.setString(argIdx++, Description); if (IsSecure) { stmtCreateByPKey.setString(argIdx++, "Y"); } else { stmtCreateByPKey.setString(argIdx++, "N"); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFInternetURLProtocolBuff createdBuff = unpackURLProtocolResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredURLProtocolId(createdBuff.getRequiredURLProtocolId()); Buff.setRequiredName(createdBuff.getRequiredName()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setRequiredIsSecure(createdBuff.getRequiredIsSecure()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }