Example usage for java.sql Types SMALLINT

List of usage examples for java.sql Types SMALLINT

Introduction

In this page you can find the example usage for java.sql Types SMALLINT.

Prototype

int SMALLINT

To view the source code for java.sql Types SMALLINT.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type SMALLINT.

Usage

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

public CFCrmAddressBuff[] readBuffByCountryIdx(CFCrmAuthorization Authorization, Short CountryId) {
    final String S_ProcName = "readBuffByCountryIdx";
    ResultSet resultSet = null;/*w  ww  .  ja v a  2 s .  co  m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_address_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }";
        if (stmtReadBuffByCountryIdx == null) {
            stmtReadBuffByCountryIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByCountryIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByCountryIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByCountryIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (CountryId != null) {
            stmtReadBuffByCountryIdx.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtReadBuffByCountryIdx.executeQuery();
        List<CFCrmAddressBuff> buffList = new LinkedList<CFCrmAddressBuff>();
        if (resultSet != null) {
            while (resultSet.next()) {
                CFCrmAddressBuff buff = unpackAddressResultSetToBuff(resultSet);
                buffList.add(buff);
            }
        }
        int idx = 0;
        CFCrmAddressBuff[] retBuff = new CFCrmAddressBuff[buffList.size()];
        Iterator<CFCrmAddressBuff> 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.cfinternet.v2_1.CFInternetOracle.CFInternetOracleISOLanguageTable.java

public void updateISOLanguage(CFInternetAuthorization Authorization, CFInternetISOLanguageBuff Buff) {
    final String S_ProcName = "updateISOLanguage";
    ResultSet resultSet = null;//from www.  j ava2 s .  c  o  m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFInternetISOLanguageBuff> buffList = new LinkedList<CFInternetISOLanguageBuff>();
    try {
        short Id = Buff.getRequiredId();
        String ISOCode = Buff.getRequiredISOCode();
        String BaseLanguageCode = Buff.getRequiredBaseLanguageCode();
        Short ISOCountryId = Buff.getOptionalISOCountryId();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx
                .prepareCall("begin " + schema.getLowerDbSchemaName() + ".upd_iso_lang( ?, ?, ?, ?, ?, ?, ?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ISLN");
        stmtUpdateByPKey.setShort(argIdx++, Id);
        stmtUpdateByPKey.setString(argIdx++, ISOCode);
        stmtUpdateByPKey.setString(argIdx++, BaseLanguageCode);
        if (ISOCountryId != null) {
            stmtUpdateByPKey.setShort(argIdx++, ISOCountryId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFInternetISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredISOCode(updatedBuff.getRequiredISOCode());
                    Buff.setRequiredBaseLanguageCode(updatedBuff.getRequiredBaseLanguageCode());
                    Buff.setOptionalISOCountryId(updatedBuff.getOptionalISOCountryId());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_iso_lang() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_iso_lang() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityOracle.CFSecurityOracleISOLanguageTable.java

public void updateISOLanguage(CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    final String S_ProcName = "updateISOLanguage";
    ResultSet resultSet = null;/*  www  . java  2  s. co  m*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFSecurityISOLanguageBuff> buffList = new LinkedList<CFSecurityISOLanguageBuff>();
    try {
        short Id = Buff.getRequiredId();
        String ISOCode = Buff.getRequiredISOCode();
        String BaseLanguageCode = Buff.getRequiredBaseLanguageCode();
        Short ISOCountryId = Buff.getOptionalISOCountryId();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx
                .prepareCall("begin " + schema.getLowerSchemaDbName() + ".upd_iso_lang( ?, ?, ?, ?, ?, ?, ?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ISLN");
        stmtUpdateByPKey.setShort(argIdx++, Id);
        stmtUpdateByPKey.setString(argIdx++, ISOCode);
        stmtUpdateByPKey.setString(argIdx++, BaseLanguageCode);
        if (ISOCountryId != null) {
            stmtUpdateByPKey.setShort(argIdx++, ISOCountryId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFSecurityISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredISOCode(updatedBuff.getRequiredISOCode());
                    Buff.setRequiredBaseLanguageCode(updatedBuff.getRequiredBaseLanguageCode());
                    Buff.setOptionalISOCountryId(updatedBuff.getOptionalISOCountryId());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_iso_lang() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_iso_lang() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

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

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

public void updateContactURL(CFCrmAuthorization Authorization, CFCrmContactURLBuff Buff) {
    final String S_ProcName = "updateContactURL";
    ResultSet resultSet = null;/*from   ww w.jav a  2s . c  o  m*/
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactURLId = Buff.getRequiredContactURLId();
        long ContactId = Buff.getRequiredContactId();
        Short URLProtocolId = Buff.getOptionalURLProtocolId();
        String Name = Buff.getRequiredName();
        String URL = Buff.getRequiredURL();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_update_ctcurl ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?";
        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++, "CURL");
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setLong(argIdx++, ContactURLId);
        stmtUpdateByPKey.setLong(argIdx++, ContactId);
        if (URLProtocolId != null) {
            stmtUpdateByPKey.setShort(argIdx++, URLProtocolId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setString(argIdx++, Name);
        stmtUpdateByPKey.setString(argIdx++, URL);
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        boolean moreResults = true;
        resultSet = null;
        while (resultSet == null) {
            try {
                moreResults = stmtUpdateByPKey.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    resultSet = stmtUpdateByPKey.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtUpdateByPKey.getUpdateCount()) {
                break;
            }
        }
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "resultSet");
        }
        if (resultSet.next()) {
            CFCrmContactURLBuff updatedBuff = unpackContactURLResultSetToBuff(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.setOptionalURLProtocolId(updatedBuff.getOptionalURLProtocolId());
            Buff.setRequiredName(updatedBuff.getRequiredName());
            Buff.setRequiredURL(updatedBuff.getRequiredURL());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleISOLanguageTable.java

public void updateISOLanguage(CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    final String S_ProcName = "updateISOLanguage";
    ResultSet resultSet = null;//from  w  ww .  j a v a  2s  .c  o  m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFSecurityISOLanguageBuff> buffList = new LinkedList<CFSecurityISOLanguageBuff>();
    try {
        short Id = Buff.getRequiredId();
        String ISOCode = Buff.getRequiredISOCode();
        String BaseLanguageCode = Buff.getRequiredBaseLanguageCode();
        Short ISOCountryId = Buff.getOptionalISOCountryId();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx
                .prepareCall("begin " + schema.getLowerDbSchemaName() + ".upd_iso_lang( ?, ?, ?, ?, ?, ?, ?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ISLN");
        stmtUpdateByPKey.setShort(argIdx++, Id);
        stmtUpdateByPKey.setString(argIdx++, ISOCode);
        stmtUpdateByPKey.setString(argIdx++, BaseLanguageCode);
        if (ISOCountryId != null) {
            stmtUpdateByPKey.setShort(argIdx++, ISOCountryId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFSecurityISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredISOCode(updatedBuff.getRequiredISOCode());
                    Buff.setRequiredBaseLanguageCode(updatedBuff.getRequiredBaseLanguageCode());
                    Buff.setOptionalISOCountryId(updatedBuff.getOptionalISOCountryId());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_iso_lang() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_iso_lang() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

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

public CFCrmAddressBuff[] readBuffByCountryIdx(CFCrmAuthorization Authorization, Short CountryId) {
    final String S_ProcName = "readBuffByCountryIdx";
    ResultSet resultSet = null;/* ww  w .j av a  2 s.c  o  m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_address_by_countryidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByCountryIdx == null) {
            stmtReadBuffByCountryIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByCountryIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByCountryIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByCountryIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (CountryId != null) {
            stmtReadBuffByCountryIdx.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        try {
            resultSet = stmtReadBuffByCountryIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFCrmAddressBuff> buffList = new LinkedList<CFCrmAddressBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFCrmAddressBuff buff = unpackAddressResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFCrmAddressBuff[] retBuff = new CFCrmAddressBuff[buffList.size()];
        Iterator<CFCrmAddressBuff> 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:com.etcc.csc.dao.OraclePaymentDAO.java

/**
 * No payment Checkout: check out the retail transaction passed to this 
 * method. Make sure this method is called only when there is no payment
 * expected.//  www  .j  a v  a  2 s .c o  m
 * 
 * @param accountId
 * @param dbSessionId
 * @param ipAddress
 * @param loginId
 * @param retailTransId
 * @return
 * @throws EtccException
 * @throws Exception
 */
public boolean noPaymentCheckout(long accountId, String dbSessionId, String ipAddress, String loginId,
        long retailTransId) throws EtccException, Exception {
    boolean success = false;
    try {
        setConnection(Util.getDbConnection());

        /*
          FUNCTION no_payment_checkout(p_acct_id        IN accounts.acct_id%TYPE,
                        p_session_id    IN VARCHAR2,
                        p_ip_address    IN VARCHAR2,
                        p_user_id       IN VARCHAR2,
                        p_rtl_trxn_id   IN NUMBER,
                        o_error_msg_arr OUT olc_error_msg_arr,
                        p_called_from_ui      boolean default TRUE)
          RETURN NUMBER
         */

        setConnection(Util.getDbConnection());

        Map typeMap = new HashMap();
        typeMap.put("TAG_OWNER.OLC_ERROR_MSG_REC", ErrorMsgRec.class);
        conn.setTypeMap(typeMap);

        cstmt = conn.prepareCall("{? = call OLCSC_ACCT_MGMT.NO_PAYMENT_CHECKOUT(?,?,?,?,?,?)}");

        cstmt.registerOutParameter(1, Types.SMALLINT);
        cstmt.setLong(2, accountId);
        cstmt.setString(3, dbSessionId);
        cstmt.setString(4, ipAddress);
        cstmt.setString(5, loginId);
        cstmt.setLong(6, retailTransId);
        cstmt.registerOutParameter(7, Types.ARRAY, "TAG_OWNER.OLC_ERROR_MSG_ARR");
        cstmt.execute();
        int result = cstmt.getInt(1);
        if (result == -1) {
            logger.info("security exception: activateTag");
            throw new EtccSecurityException("security exception in activateTag");
        } else if (result == 1) {
            success = true;
        } else {
            Collection errors = Util.convertErrorMsgs(cstmt.getArray(7));
            Iterator iter = errors.iterator();
            while (iter.hasNext()) {
                ErrorMessageDTO errorDTO = (ErrorMessageDTO) iter.next();
                logger.error("Error occured in noPaymentCheckout:" + errorDTO.getMessage());
            }
        }
        logger.info("No payment checkout, Success? " + success);
    } catch (Throwable t) {
        throw new EtccException("Error running noPaymentCheckout: ", t);
    } finally {
        closeConnection();
    }
    return success;
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswOracle.CFFswOracleISOLanguageTable.java

public void updateISOLanguage(CFFswAuthorization Authorization, CFFswISOLanguageBuff Buff) {
    final String S_ProcName = "updateISOLanguage";
    ResultSet resultSet = null;/*from   w w w.  j  a  va  2s  .c o m*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFFswISOLanguageBuff> buffList = new LinkedList<CFFswISOLanguageBuff>();
    try {
        short Id = Buff.getRequiredId();
        String ISOCode = Buff.getRequiredISOCode();
        String BaseLanguageCode = Buff.getRequiredBaseLanguageCode();
        Short ISOCountryId = Buff.getOptionalISOCountryId();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx
                .prepareCall("begin " + schema.getLowerDbSchemaName() + ".upd_iso_lang( ?, ?, ?, ?, ?, ?, ?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ISLN");
        stmtUpdateByPKey.setShort(argIdx++, Id);
        stmtUpdateByPKey.setString(argIdx++, ISOCode);
        stmtUpdateByPKey.setString(argIdx++, BaseLanguageCode);
        if (ISOCountryId != null) {
            stmtUpdateByPKey.setShort(argIdx++, ISOCountryId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFFswISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredISOCode(updatedBuff.getRequiredISOCode());
                    Buff.setRequiredBaseLanguageCode(updatedBuff.getRequiredBaseLanguageCode());
                    Buff.setOptionalISOCountryId(updatedBuff.getOptionalISOCountryId());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_iso_lang() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_iso_lang() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstOracle.CFAstOracleISOLanguageTable.java

public void updateISOLanguage(CFAstAuthorization Authorization, CFAstISOLanguageBuff Buff) {
    final String S_ProcName = "updateISOLanguage";
    ResultSet resultSet = null;//  w w  w.j  a  v  a  2s.  co m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFAstISOLanguageBuff> buffList = new LinkedList<CFAstISOLanguageBuff>();
    try {
        short Id = Buff.getRequiredId();
        String ISOCode = Buff.getRequiredISOCode();
        String BaseLanguageCode = Buff.getRequiredBaseLanguageCode();
        Short ISOCountryId = Buff.getOptionalISOCountryId();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx
                .prepareCall("begin " + schema.getLowerSchemaDbName() + ".upd_iso_lang( ?, ?, ?, ?, ?, ?, ?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ISLN");
        stmtUpdateByPKey.setShort(argIdx++, Id);
        stmtUpdateByPKey.setString(argIdx++, ISOCode);
        stmtUpdateByPKey.setString(argIdx++, BaseLanguageCode);
        if (ISOCountryId != null) {
            stmtUpdateByPKey.setShort(argIdx++, ISOCountryId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFAstISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredISOCode(updatedBuff.getRequiredISOCode());
                    Buff.setRequiredBaseLanguageCode(updatedBuff.getRequiredBaseLanguageCode());
                    Buff.setOptionalISOCountryId(updatedBuff.getOptionalISOCountryId());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_iso_lang() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_iso_lang() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}