Java tutorial
// Description: Java 7 DB/2 LUW 10.5 Jdbc DbIO implementation for Cluster. /* * CF Customer Relations Management model * * Copyright (c) 2014 Mark Sobkow * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW; import java.math.*; import java.sql.*; import java.text.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v2_1.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrm.*; /* * CFCrmDb2LUWClusterTable DB/2 LUW 10.5 Jdbc DbIO implementation * for Cluster. */ public class CFCrmDb2LUWClusterTable implements ICFCrmClusterTable { private CFCrmDb2LUWSchema schema; protected PreparedStatement stmtReadBuffByPKey = null; protected PreparedStatement stmtLockBuffByPKey = null; protected PreparedStatement stmtCreateByPKey = null; protected PreparedStatement stmtUpdateByPKey = null; protected PreparedStatement stmtDeleteByPKey = null; protected PreparedStatement stmtReadAllBuff = null; protected PreparedStatement stmtReadBuffByIdIdx = null; protected PreparedStatement stmtReadBuffByUDomainNameIdx = null; protected PreparedStatement stmtReadBuffByUDescrIdx = null; protected PreparedStatement stmtDeleteByIdIdx = null; protected PreparedStatement stmtDeleteByUDomainNameIdx = null; protected PreparedStatement stmtDeleteByUDescrIdx = null; protected PreparedStatement stmtSelectNextSecAppIdGen = null; protected PreparedStatement stmtSelectNextSecFormIdGen = null; protected PreparedStatement stmtSelectNextSecGroupIdGen = null; protected PreparedStatement stmtSelectNextSecGroupMemberIdGen = null; protected PreparedStatement stmtSelectNextSecGroupIncludeIdGen = null; protected PreparedStatement stmtSelectNextSecGroupFormIdGen = null; protected PreparedStatement stmtSelectNextServiceIdGen = null; protected PreparedStatement stmtSelectNextHostNodeIdGen = null; public CFCrmDb2LUWClusterTable(CFCrmDb2LUWSchema argSchema) { schema = argSchema; } public int nextSecAppIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextSecAppIdGen"; final String sqlSelectNext = "call sf_next_secappidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextSecAppIdGen == null) { stmtSelectNextSecAppIdGen = cnx.prepareStatement(sqlSelectNext); } int nextId; int argIdx = 1; stmtSelectNextSecAppIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextSecAppIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getInt(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextSecAppIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_secappidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public int nextSecAppIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); int retval = nextSecAppIdGen(Authorization, pkey); return (retval); } public int nextSecFormIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextSecFormIdGen"; final String sqlSelectNext = "call sf_next_secformidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextSecFormIdGen == null) { stmtSelectNextSecFormIdGen = cnx.prepareStatement(sqlSelectNext); } int nextId; int argIdx = 1; stmtSelectNextSecFormIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextSecFormIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getInt(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextSecFormIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_secformidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public int nextSecFormIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); int retval = nextSecFormIdGen(Authorization, pkey); return (retval); } public int nextSecGroupIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextSecGroupIdGen"; final String sqlSelectNext = "call sf_next_secgroupidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextSecGroupIdGen == null) { stmtSelectNextSecGroupIdGen = cnx.prepareStatement(sqlSelectNext); } int nextId; int argIdx = 1; stmtSelectNextSecGroupIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextSecGroupIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getInt(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextSecGroupIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_secgroupidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public int nextSecGroupIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); int retval = nextSecGroupIdGen(Authorization, pkey); return (retval); } public long nextSecGroupMemberIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextSecGroupMemberIdGen"; final String sqlSelectNext = "call sf_next_secgroupmemberidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextSecGroupMemberIdGen == null) { stmtSelectNextSecGroupMemberIdGen = cnx.prepareStatement(sqlSelectNext); } long nextId; int argIdx = 1; stmtSelectNextSecGroupMemberIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextSecGroupMemberIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getLong(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextSecGroupMemberIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_secgroupmemberidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public long nextSecGroupMemberIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); long retval = nextSecGroupMemberIdGen(Authorization, pkey); return (retval); } public long nextSecGroupIncludeIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextSecGroupIncludeIdGen"; final String sqlSelectNext = "call sf_next_secgroupincludeidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextSecGroupIncludeIdGen == null) { stmtSelectNextSecGroupIncludeIdGen = cnx.prepareStatement(sqlSelectNext); } long nextId; int argIdx = 1; stmtSelectNextSecGroupIncludeIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextSecGroupIncludeIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getLong(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextSecGroupIncludeIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_secgroupincludeidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public long nextSecGroupIncludeIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); long retval = nextSecGroupIncludeIdGen(Authorization, pkey); return (retval); } public long nextSecGroupFormIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextSecGroupFormIdGen"; final String sqlSelectNext = "call sf_next_secgroupformidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextSecGroupFormIdGen == null) { stmtSelectNextSecGroupFormIdGen = cnx.prepareStatement(sqlSelectNext); } long nextId; int argIdx = 1; stmtSelectNextSecGroupFormIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextSecGroupFormIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getLong(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextSecGroupFormIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_secgroupformidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public long nextSecGroupFormIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); long retval = nextSecGroupFormIdGen(Authorization, pkey); return (retval); } public long nextServiceIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextServiceIdGen"; final String sqlSelectNext = "call sf_next_serviceidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextServiceIdGen == null) { stmtSelectNextServiceIdGen = cnx.prepareStatement(sqlSelectNext); } long nextId; int argIdx = 1; stmtSelectNextServiceIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextServiceIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getLong(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextServiceIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_serviceidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public long nextServiceIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); long retval = nextServiceIdGen(Authorization, pkey); return (retval); } public long nextHostNodeIdGen(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "nextHostNodeIdGen"; final String sqlSelectNext = "call sf_next_hostnodeidgen(" + "?" + " )"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet rsSelect = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); if (stmtSelectNextHostNodeIdGen == null) { stmtSelectNextHostNodeIdGen = cnx.prepareStatement(sqlSelectNext); } long nextId; int argIdx = 1; stmtSelectNextHostNodeIdGen.setLong(argIdx++, Id); rsSelect = stmtSelectNextHostNodeIdGen.executeQuery(); if (rsSelect.next()) { nextId = rsSelect.getLong(1); if (rsSelect.wasNull()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "NextHostNodeIdGen cannot be null!"); } if (rsSelect.next()) { rsSelect.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 result row to be returned by sf_next_hostnodeidgen(), not 0"); } return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (rsSelect != null) { try { rsSelect.close(); } catch (SQLException e) { } rsSelect = null; } } } public long nextHostNodeIdGen(CFCrmAuthorization Authorization, long argId) { CFCrmClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(argId); long retval = nextHostNodeIdGen(Authorization, pkey); return (retval); } public void createCluster(CFCrmAuthorization Authorization, CFCrmClusterBuff Buff) { final String S_ProcName = "createCluster"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { String FullDomainName = Buff.getRequiredFullDomainName(); String Description = Buff.getRequiredDescription(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_create_clus( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; 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++, "CLUS"); stmtCreateByPKey.setString(argIdx++, FullDomainName); stmtCreateByPKey.setString(argIdx++, Description); resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff createdBuff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setRequiredFullDomainName(createdBuff.getRequiredFullDomainName()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); 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; } } } protected static String S_sqlSelectClusterDistinctClassCode = null; public String getSqlSelectClusterDistinctClassCode() { if (S_sqlSelectClusterDistinctClassCode == null) { S_sqlSelectClusterDistinctClassCode = "SELECT " + "DISTINCT clus.ClassCode " + "FROM " + schema.getLowerDbSchemaName() + ".clus AS clus "; } return (S_sqlSelectClusterDistinctClassCode); } protected static String S_sqlSelectClusterBuff = null; public String getSqlSelectClusterBuff() { if (S_sqlSelectClusterBuff == null) { S_sqlSelectClusterBuff = "SELECT " + "clus.Id, " + "clus.FullDomainName, " + "clus.Description, " + "clus.Revision " + "FROM " + schema.getLowerDbSchemaName() + ".clus AS clus "; } return (S_sqlSelectClusterBuff); } protected CFCrmClusterBuff unpackClusterResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackClusterResultSetToBuff"; int idxcol = 1; CFCrmClusterBuff buff = schema.getFactoryCluster().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(CFCrmDb2LUWSchema.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(CFCrmDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredFullDomainName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); } public CFCrmClusterBuff readDerived(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "readDerived"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFCrmClusterBuff buff; buff = readBuff(Authorization, PKey); return (buff); } public CFCrmClusterBuff lockDerived(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "lockDerived"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFCrmClusterBuff buff; buff = lockBuff(Authorization, PKey); return (buff); } public CFCrmClusterBuff[] readAllDerived(CFCrmAuthorization Authorization) { final String S_ProcName = "readAllDerived"; CFCrmClusterBuff[] buffArray; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buffArray = readAllBuff(Authorization); return (buffArray); } public CFCrmClusterBuff readDerivedByIdIdx(CFCrmAuthorization Authorization, long Id) { final String S_ProcName = "CFCrmDb2LUWClusterTable.readDerivedByIdIdx() "; CFCrmClusterBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByIdIdx(Authorization, Id); return (buff); } public CFCrmClusterBuff readDerivedByUDomainNameIdx(CFCrmAuthorization Authorization, String FullDomainName) { final String S_ProcName = "CFCrmDb2LUWClusterTable.readDerivedByUDomainNameIdx() "; CFCrmClusterBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByUDomainNameIdx(Authorization, FullDomainName); return (buff); } public CFCrmClusterBuff readDerivedByUDescrIdx(CFCrmAuthorization Authorization, String Description) { final String S_ProcName = "CFCrmDb2LUWClusterTable.readDerivedByUDescrIdx() "; CFCrmClusterBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByUDescrIdx(Authorization, Description); return (buff); } public CFCrmClusterBuff readBuff(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "readBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); final String sql = "CALL sp_read_clus( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByPKey == null) { stmtReadBuffByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByPKey.setLong(argIdx++, Id); resultSet = stmtReadBuffByPKey.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFCrmClusterBuff lockBuff(CFCrmAuthorization Authorization, CFCrmClusterPKey PKey) { final String S_ProcName = "lockBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); final String sql = "CALL sp_lock_clus( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtLockBuffByPKey == null) { stmtLockBuffByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtLockBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtLockBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtLockBuffByPKey.setLong(argIdx++, Id); resultSet = stmtLockBuffByPKey.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFCrmClusterBuff[] readAllBuff(CFCrmAuthorization Authorization) { final String S_ProcName = "readAllBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_clus_all( ?, ?, ?, ?, ? )"; if (stmtReadAllBuff == null) { stmtReadAllBuff = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); resultSet = stmtReadAllBuff.executeQuery(); List<CFCrmClusterBuff> buffList = new LinkedList<CFCrmClusterBuff>(); while (resultSet.next()) { CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFCrmClusterBuff[] retBuff = new CFCrmClusterBuff[buffList.size()]; Iterator<CFCrmClusterBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFCrmClusterBuff readBuffByIdIdx(CFCrmAuthorization Authorization, long Id) { final String S_ProcName = "readBuffByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_clus_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByIdIdx == null) { stmtReadBuffByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByIdIdx.setLong(argIdx++, Id); resultSet = stmtReadBuffByIdIdx.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFCrmClusterBuff readBuffByUDomainNameIdx(CFCrmAuthorization Authorization, String FullDomainName) { final String S_ProcName = "readBuffByUDomainNameIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_clus_by_udomainnameidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByUDomainNameIdx == null) { stmtReadBuffByUDomainNameIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByUDomainNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDomainNameIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDomainNameIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDomainNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDomainNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDomainNameIdx.setString(argIdx++, FullDomainName); resultSet = stmtReadBuffByUDomainNameIdx.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFCrmClusterBuff readBuffByUDescrIdx(CFCrmAuthorization Authorization, String Description) { final String S_ProcName = "readBuffByUDescrIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_clus_by_udescridx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByUDescrIdx == null) { stmtReadBuffByUDescrIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByUDescrIdx.setString(argIdx++, Description); resultSet = stmtReadBuffByUDescrIdx.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void updateCluster(CFCrmAuthorization Authorization, CFCrmClusterBuff Buff) { final String S_ProcName = "updateCluster"; if ("CLUS".equals(Buff.getClassCode()) && (!schema.isSystemUser(Authorization))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- only system user can modify Cluster data"); } ResultSet resultSet = null; try { long Id = Buff.getRequiredId(); String FullDomainName = Buff.getRequiredFullDomainName(); String Description = Buff.getRequiredDescription(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_clus( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CLUS"); stmtUpdateByPKey.setLong(argIdx++, Id); stmtUpdateByPKey.setString(argIdx++, FullDomainName); stmtUpdateByPKey.setString(argIdx++, Description); stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFCrmClusterBuff updatedBuff = unpackClusterResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredFullDomainName(updatedBuff.getRequiredFullDomainName()); Buff.setRequiredDescription(updatedBuff.getRequiredDescription()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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; } } } public void deleteCluster(CFCrmAuthorization Authorization, CFCrmClusterBuff Buff) { final String S_ProcName = "deleteCluster"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); long Id = Buff.getRequiredId(); final String sql = "CALL sp_delete_clus( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByPKey == null) { stmtDeleteByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setLong(argIdx++, Id); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; resultSet = stmtDeleteByPKey.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteClusterByIdIdx(CFCrmAuthorization Authorization, long argId) { final String S_ProcName = "deleteClusterByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_clus_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setLong(argIdx++, argId); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteClusterByIdIdx(CFCrmAuthorization Authorization, CFCrmClusterPKey argKey) { deleteClusterByIdIdx(Authorization, argKey.getRequiredId()); } public void deleteClusterByUDomainNameIdx(CFCrmAuthorization Authorization, String argFullDomainName) { final String S_ProcName = "deleteClusterByUDomainNameIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_clus_by_udomainnameidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByUDomainNameIdx == null) { stmtDeleteByUDomainNameIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByUDomainNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByUDomainNameIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByUDomainNameIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByUDomainNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByUDomainNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByUDomainNameIdx.setString(argIdx++, argFullDomainName); resultSet = stmtDeleteByUDomainNameIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteClusterByUDomainNameIdx(CFCrmAuthorization Authorization, CFCrmClusterByUDomainNameIdxKey argKey) { deleteClusterByUDomainNameIdx(Authorization, argKey.getRequiredFullDomainName()); } public void deleteClusterByUDescrIdx(CFCrmAuthorization Authorization, String argDescription) { final String S_ProcName = "deleteClusterByUDescrIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_clus_by_udescridx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByUDescrIdx == null) { stmtDeleteByUDescrIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByUDescrIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByUDescrIdx.setString(argIdx++, argDescription); resultSet = stmtDeleteByUDescrIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteClusterByUDescrIdx(CFCrmAuthorization Authorization, CFCrmClusterByUDescrIdxKey argKey) { deleteClusterByUDescrIdx(Authorization, argKey.getRequiredDescription()); } public CFCrmCursor openClusterCursorAll(CFCrmAuthorization Authorization) { String sql = getSqlSelectClusterBuff() + "ORDER BY " + "clus.Id ASC"; CFCrmCursor cursor = new CFCrmDb2LUWCursor(Authorization, schema, sql); return (cursor); } public void closeClusterCursor(CFCrmCursor Cursor) { try { Cursor.getResultSet().close(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "closeClusterCursor", e); } } public CFCrmClusterBuff nextClusterCursor(CFCrmCursor Cursor) { final String S_ProcName = "nextClusterCursor"; try { ResultSet resultSet = Cursor.getResultSet(); if (!resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "No more results available"); } CFCrmClusterBuff buff = unpackClusterResultSetToBuff(resultSet); return (buff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public CFCrmClusterBuff prevClusterCursor(CFCrmCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFCrmClusterBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextClusterCursor(Cursor); } return (buff); } public CFCrmClusterBuff firstClusterCursor(CFCrmCursor Cursor) { int targetRowIdx = 1; CFCrmClusterBuff buff = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { buff = nextClusterCursor(Cursor); } return (buff); } public CFCrmClusterBuff lastClusterCursor(CFCrmCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastClusterCursor"); } public CFCrmClusterBuff nthClusterCursor(CFCrmCursor Cursor, int Idx) { int targetRowIdx = Idx; CFCrmClusterBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextClusterCursor(Cursor); } return (buff); } /** * Release the prepared statements. * <p> * When the schema changes connections, the prepared statements * have to be released because they contain connection-specific * information for most databases. */ public void releasePreparedStatements() { final String S_ProcName = "releasePreparedStatements"; S_sqlSelectClusterDistinctClassCode = null; S_sqlSelectClusterBuff = null; if (stmtReadBuffByPKey != null) { try { stmtReadBuffByPKey.close(); } catch (SQLException e) { } stmtReadBuffByPKey = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } if (stmtLockBuffByPKey != null) { try { stmtLockBuffByPKey.close(); } catch (SQLException e) { } stmtLockBuffByPKey = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } if (stmtUpdateByPKey != null) { try { stmtUpdateByPKey.close(); } catch (SQLException e) { } stmtUpdateByPKey = null; } if (stmtDeleteByPKey != null) { try { stmtDeleteByPKey.close(); } catch (SQLException e) { } stmtDeleteByPKey = null; } if (stmtDeleteByIdIdx != null) { try { stmtDeleteByIdIdx.close(); } catch (SQLException e) { } stmtDeleteByIdIdx = null; } if (stmtDeleteByUDomainNameIdx != null) { try { stmtDeleteByUDomainNameIdx.close(); } catch (SQLException e) { } stmtDeleteByUDomainNameIdx = null; } if (stmtDeleteByUDescrIdx != null) { try { stmtDeleteByUDescrIdx.close(); } catch (SQLException e) { } stmtDeleteByUDescrIdx = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } if (stmtReadBuffByIdIdx != null) { try { stmtReadBuffByIdIdx.close(); } catch (SQLException e) { } stmtReadBuffByIdIdx = null; } if (stmtReadBuffByUDomainNameIdx != null) { try { stmtReadBuffByUDomainNameIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDomainNameIdx = null; } if (stmtReadBuffByUDescrIdx != null) { try { stmtReadBuffByUDescrIdx.close(); } catch (SQLException e) { } stmtReadBuffByUDescrIdx = null; } if (stmtSelectNextSecAppIdGen != null) { try { stmtSelectNextSecAppIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecAppIdGen = null; } if (stmtSelectNextSecFormIdGen != null) { try { stmtSelectNextSecFormIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecFormIdGen = null; } if (stmtSelectNextSecGroupIdGen != null) { try { stmtSelectNextSecGroupIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupIdGen = null; } if (stmtSelectNextSecGroupMemberIdGen != null) { try { stmtSelectNextSecGroupMemberIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupMemberIdGen = null; } if (stmtSelectNextSecGroupIncludeIdGen != null) { try { stmtSelectNextSecGroupIncludeIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupIncludeIdGen = null; } if (stmtSelectNextSecGroupFormIdGen != null) { try { stmtSelectNextSecGroupFormIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecGroupFormIdGen = null; } if (stmtSelectNextServiceIdGen != null) { try { stmtSelectNextServiceIdGen.close(); } catch (SQLException e) { } stmtSelectNextServiceIdGen = null; } if (stmtSelectNextHostNodeIdGen != null) { try { stmtSelectNextHostNodeIdGen.close(); } catch (SQLException e) { } stmtSelectNextHostNodeIdGen = null; } } }