Example usage for java.lang Short shortValue

List of usage examples for java.lang Short shortValue

Introduction

In this page you can find the example usage for java.lang Short shortValue.

Prototype

@HotSpotIntrinsicCandidate
public short shortValue() 

Source Link

Document

Returns the value of this Short as a short .

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAccountEntryTable.java

public void deleteAccountEntryByCrCcyIdx(CFAccAuthorization Authorization, Short argCreditCurrencyId) {
    final String S_ProcName = "deleteAccountEntryByCrCcyIdx";
    ResultSet resultSet = null;/*w  ww  .  j a va2s  .  c  o  m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_ac_entry_by_crccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByCrCcyIdx == null) {
            stmtDeleteByCrCcyIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByCrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argCreditCurrencyId != null) {
            stmtDeleteByCrCcyIdx.setShort(argIdx++, argCreditCurrencyId.shortValue());
        } else {
            stmtDeleteByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtDeleteByCrCcyIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAddressTable.java

public void createAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from   w w w  .  j  av  a2  s .c o  m
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_create_address( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )";
        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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccAddressBuff createdBuff = unpackAddressResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredAddressId(createdBuff.getRequiredAddressId());
            Buff.setRequiredContactId(createdBuff.getRequiredContactId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(createdBuff.getOptionalCity());
            Buff.setOptionalState(createdBuff.getOptionalState());
            Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
            Buff.setOptionalZip(createdBuff.getOptionalZip());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAccountEntryTable.java

public CFAccAccountEntryBuff[] readBuffByDrCcyIdx(CFAccAuthorization Authorization, Short DebitCurrencyId) {
    final String S_ProcName = "readBuffByDrCcyIdx";
    ResultSet resultSet = null;//from w w w .ja v a 2  s  .com
    try {
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }";
        if (stmtReadBuffByDrCcyIdx == null) {
            stmtReadBuffByDrCcyIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByDrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByDrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (DebitCurrencyId != null) {
            stmtReadBuffByDrCcyIdx.setShort(argIdx++, DebitCurrencyId.shortValue());
        } else {
            stmtReadBuffByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtReadBuffByDrCcyIdx.executeQuery();
        List<CFAccAccountEntryBuff> buffList = new LinkedList<CFAccAccountEntryBuff>();
        if (resultSet != null) {
            while (resultSet.next()) {
                CFAccAccountEntryBuff buff = unpackAccountEntryResultSetToBuff(resultSet);
                buffList.add(buff);
            }
        }
        int idx = 0;
        CFAccAccountEntryBuff[] retBuff = new CFAccAccountEntryBuff[buffList.size()];
        Iterator<CFAccAccountEntryBuff> 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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAccountEntryTable.java

public CFAccAccountEntryBuff[] readBuffByCrCcyIdx(CFAccAuthorization Authorization, Short CreditCurrencyId) {
    final String S_ProcName = "readBuffByCrCcyIdx";
    ResultSet resultSet = null;// ww w.ja v  a  2s  .c  om
    try {
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_ac_entry_by_crccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }";
        if (stmtReadBuffByCrCcyIdx == null) {
            stmtReadBuffByCrCcyIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByCrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByCrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (CreditCurrencyId != null) {
            stmtReadBuffByCrCcyIdx.setShort(argIdx++, CreditCurrencyId.shortValue());
        } else {
            stmtReadBuffByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtReadBuffByCrCcyIdx.executeQuery();
        List<CFAccAccountEntryBuff> buffList = new LinkedList<CFAccAccountEntryBuff>();
        if (resultSet != null) {
            while (resultSet.next()) {
                CFAccAccountEntryBuff buff = unpackAccountEntryResultSetToBuff(resultSet);
                buffList.add(buff);
            }
        }
        int idx = 0;
        CFAccAccountEntryBuff[] retBuff = new CFAccAccountEntryBuff[buffList.size()];
        Iterator<CFAccAccountEntryBuff> 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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlAddressTable.java

public void createAddress(CFCrmAuthorization Authorization, CFCrmAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*  w  ww  .  j a va2 s .  co m*/
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_create_address ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?";
        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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.execute();
        boolean moreResults = true;
        resultSet = null;
        while (resultSet == null) {
            try {
                moreResults = stmtCreateByPKey.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    resultSet = stmtCreateByPKey.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtCreateByPKey.getUpdateCount()) {
                break;
            }
        }
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "resultSet");
        }
        if (resultSet.next()) {
            CFCrmAddressBuff createdBuff = unpackAddressResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredAddressId(createdBuff.getRequiredAddressId());
            Buff.setRequiredContactId(createdBuff.getRequiredContactId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(createdBuff.getOptionalCity());
            Buff.setOptionalState(createdBuff.getOptionalState());
            Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
            Buff.setOptionalZip(createdBuff.getOptionalZip());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlAddressTable.java

public void createAddress(CFCrmAuthorization Authorization, CFCrmAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from ww w  . java2 s .c  o  m
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_address( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFCrmAddressBuff createdBuff = unpackAddressResultSetToBuff(resultSet);
            if ((resultSet != null) && resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredAddressId(createdBuff.getRequiredAddressId());
            Buff.setRequiredContactId(createdBuff.getRequiredContactId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(createdBuff.getOptionalCity());
            Buff.setOptionalState(createdBuff.getOptionalState());
            Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
            Buff.setOptionalZip(createdBuff.getOptionalZip());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAddressTable.java

public void createAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*w  w w. j  a  v a 2 s. c  o  m*/
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_create_address ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?";
        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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.execute();
        boolean moreResults = true;
        resultSet = null;
        while (resultSet == null) {
            try {
                moreResults = stmtCreateByPKey.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    resultSet = stmtCreateByPKey.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtCreateByPKey.getUpdateCount()) {
                break;
            }
        }
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "resultSet");
        }
        if (resultSet.next()) {
            CFAccAddressBuff createdBuff = unpackAddressResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredAddressId(createdBuff.getRequiredAddressId());
            Buff.setRequiredContactId(createdBuff.getRequiredContactId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(createdBuff.getOptionalCity());
            Buff.setOptionalState(createdBuff.getOptionalState());
            Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
            Buff.setOptionalZip(createdBuff.getOptionalZip());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlAddressTable.java

public void createAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from   w  w  w  .  j a va 2 s .c  o m*/
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_address( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFAccAddressBuff createdBuff = unpackAddressResultSetToBuff(resultSet);
            if ((resultSet != null) && resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredAddressId(createdBuff.getRequiredAddressId());
            Buff.setRequiredContactId(createdBuff.getRequiredContactId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(createdBuff.getOptionalCity());
            Buff.setOptionalState(createdBuff.getOptionalState());
            Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
            Buff.setOptionalZip(createdBuff.getOptionalZip());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAddressTable.java

public void createAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//w w  w  . j  ava  2  s  .  co m
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_create_address( ?, ?, ?, ?, ?, ?"
                + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + ", " + "?" + " )";
        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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccAddressBuff createdBuff = unpackAddressResultSetToBuff(resultSet);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredAddressId(createdBuff.getRequiredAddressId());
            Buff.setRequiredContactId(createdBuff.getRequiredContactId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(createdBuff.getOptionalCity());
            Buff.setOptionalState(createdBuff.getOptionalState());
            Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
            Buff.setOptionalZip(createdBuff.getOptionalZip());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmDb2LUW.CFCrmDb2LUWAddressTable.java

public void updateAddress(CFCrmAuthorization Authorization, CFCrmAddressBuff Buff) {
    final String S_ProcName = "updateAddress";
    if ("ADR".equals(Buff.getClassCode())
            && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateAddress"))) {
        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                "Permission denied -- User not part of TSecGroup UpdateAddress");
    }/* w  w  w.j ava 2s .  c om*/
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long AddressId = Buff.getRequiredAddressId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_update_address( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + " )";
        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++, "ADR");
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setLong(argIdx++, AddressId);
        stmtUpdateByPKey.setLong(argIdx++, ContactId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtUpdateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtUpdateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtUpdateByPKey.setString(argIdx++, City);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtUpdateByPKey.setString(argIdx++, State);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtUpdateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtUpdateByPKey.setString(argIdx++, Zip);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        resultSet = stmtUpdateByPKey.executeQuery();
        if (resultSet.next()) {
            CFCrmAddressBuff updatedBuff = unpackAddressResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredContactId(updatedBuff.getRequiredContactId());
            Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
            Buff.setOptionalAddrLine1(updatedBuff.getOptionalAddrLine1());
            Buff.setOptionalAddrLine2(updatedBuff.getOptionalAddrLine2());
            Buff.setOptionalCity(updatedBuff.getOptionalCity());
            Buff.setOptionalState(updatedBuff.getOptionalState());
            Buff.setOptionalCountryId(updatedBuff.getOptionalCountryId());
            Buff.setOptionalZip(updatedBuff.getOptionalZip());
            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;
        }
    }
}