Example usage for java.sql Connection prepareCall

List of usage examples for java.sql Connection prepareCall

Introduction

In this page you can find the example usage for java.sql Connection prepareCall.

Prototype

CallableStatement prepareCall(String sql) throws SQLException;

Source Link

Document

Creates a CallableStatement object for calling database stored procedures.

Usage

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

public CFFswSecDeviceBuff[] readBuffByUserIdx(CFFswAuthorization Authorization, UUID SecUserId) {
    final String S_ProcName = "readBuffByUserIdx";
    ResultSet resultSet = null;/*from   ww w. ja  va2 s .  c o m*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByUserIdx = null;
    List<CFFswSecDeviceBuff> buffList = new LinkedList<CFFswSecDeviceBuff>();
    try {
        stmtReadBuffByUserIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".rd_secdevbyuseridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByUserIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByUserIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUserIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByUserIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByUserIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUserIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByUserIdx.setString(argIdx++, SecUserId.toString());
        stmtReadBuffByUserIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByUserIdx.getObject(1);
        if (resultSet != null) {
            try {
                while (resultSet.next()) {
                    CFFswSecDeviceBuff buff = unpackSecDeviceResultSetToBuff(resultSet);
                    buffList.add(buff);
                }
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            } catch (SQLException e) {
            }
        }
        int idx = 0;
        CFFswSecDeviceBuff[] retBuff = new CFFswSecDeviceBuff[buffList.size()];
        Iterator<CFFswSecDeviceBuff> 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;
        }
        if (stmtReadBuffByUserIdx != null) {
            try {
                stmtReadBuffByUserIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByUserIdx = null;
        }
    }
}

From source file:com.intuit.it.billing.data.BillingDAOImpl.java

/**
 * getCustomerList/*  w  w  w .j  a va2 s  .  c  o m*/
 * 
 * <p/>
 * <p/>
 * <b>DATABASE PROCEDURE:</b>
 *  
 * @code
 *FUNCTION fn_search_customers
 * (
 *    phone      IN VARCHAR2,
 *    first_name IN VARCHAR2,
 *    last_name  IN VARCHAR2,
 *    company    IN VARCHAR2,
 *    cc_num     IN VARCHAR2,
 *    eft_num    IN VARCHAR2,
 *    records    IN INTEGER
 *  )
 *  RETURN ref_cursor;
 * @endcode
 *  
 * <p/>
 * <b>DATABASE RESULT SET:</b>
 * <ul>
 *    <li>ACCOUNT_NO,</li>
 *    <li>FIRST_NAME,</li>
 *    <li>LAST_NAME,</li>
 *    <li>COMPANY,</li>
 *    <li>PHONE,</li>
 *    <li>ADDRESS,</li>
 *    <li>CITY,</li>
  *    <li>STATE,</li>
 *    <li>ZIP,</li>
 *    <li>COUNTRY </li>
 *  </ul>
 *  
 * @param phone - The customer's phone number
 * @param firstName -  A wild-carded first name
 * @param lastName -  A wild-carded last name
 * @param company -  A wild-carded company name
 * @param ccNum -  A four digit last-four of a credit card
 * @param eftNum -  A four digit last-four of a bank account number
 * @param pageSize  :  How many records to retrieve 
 * 
 * @return A list of Customer objects in lastname, company alphabetical order
 *         - if rows returned is greater than pageSize will not return TOO MANY rows erros
 * 
 */
@Override
public List<Customer> getCustomerList(String phone, String firstName, String lastName, String company,
        String ccNum, String eftNum, Integer pageSize)

        throws JSONException {

    Integer startPage = 1;
    List<Customer> customers = new ArrayList<Customer>();

    String query = "begin ? := billing_inquiry.fn_search_customers( ?, ?, ?, ?, ?, ?, ?, ? ); end;";

    Connection conn = null;
    ResultSet rs = null;

    // DB Connection
    try {
        conn = this.getConnection();
    } catch (SQLException e) {
        throw JSONException.sqlError(e);
    } catch (NamingException e) {
        throw JSONException.namingError(e.toString());
    }

    try {

        CallableStatement stmt = conn.prepareCall(query);
        stmt.registerOutParameter(1, OracleTypes.CURSOR);
        stmt.setString(2, phone);
        stmt.setString(3, firstName);
        stmt.setString(4, lastName);
        stmt.setString(5, company);
        stmt.setString(6, ccNum);
        stmt.setString(7, eftNum);
        stmt.setInt(8, startPage);
        stmt.setInt(9, pageSize);

        stmt.execute();
        rs = (ResultSet) stmt.getObject(1);

        while (rs.next()) {

            Customer c = new Customer();
            c.setAccountNo(rs.getString("ACCOUNT_NO"));
            c.setFirstName(rs.getString("FIRST_NAME"));
            c.setLastName(rs.getString("LAST_NAME"));
            c.setCompany(rs.getString("COMPANY"));
            c.setPhone(rs.getString("PHONE"));
            c.setAddress(rs.getString("ADDRESS"));
            c.setCity(rs.getString("CITY"));
            c.setState(rs.getString("STATE"));
            c.setZip(rs.getString("ZIP"));
            c.setCountry(rs.getString("COUNTRY"));
            customers.add(c);
        }
        conn.close();
        rs.close();

    } catch (SQLException e) {
        throw JSONException.sqlError(e);
    }

    if (customers == null || customers.isEmpty()) {
        throw JSONException.noDataFound("Null set returned - no data found");
    }

    return customers;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleServiceTypeTable.java

public CFAccServiceTypeBuff[] readAllBuff(CFAccAuthorization Authorization) {
    final String S_ProcName = "readAllBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*  w w  w .  ja v  a2  s  .com*/
    ResultSet resultSet = null;
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadAllBuff = null;
    try {
        CFAccServiceTypeBuff buff = null;
        List<CFAccServiceTypeBuff> buffList = new LinkedList<CFAccServiceTypeBuff>();
        stmtReadAllBuff = cnx.prepareCall(
                "begin " + schema.getLowerSchemaDbName() + ".rd_svctypeall( ?, ?, ?, ?, ?, ? ) ); end;");
        int argIdx = 1;
        stmtReadAllBuff.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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());
        stmtReadAllBuff.execute();
        resultSet = (ResultSet) stmtReadAllBuff.getObject(1);
        if (resultSet != null) {
            try {
                while (resultSet.next()) {
                    buff = unpackServiceTypeResultSetToBuff(resultSet);
                    buffList.add(buff);
                }
            } catch (SQLException e) {
                // Oracle may return an invalid resultSet if the rowset is empty
            }
        }
        int idx = 0;
        CFAccServiceTypeBuff[] retBuff = new CFAccServiceTypeBuff[buffList.size()];
        Iterator<CFAccServiceTypeBuff> 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;
        }
        if (stmtReadAllBuff != null) {
            try {
                stmtReadAllBuff.close();
            } catch (SQLException e) {
            }
            stmtReadAllBuff = null;
        }
    }
}

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

public CFAstServiceTypeBuff[] readAllBuff(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*  w w  w. j  a va  2s  . c om*/
    ResultSet resultSet = null;
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadAllBuff = null;
    try {
        CFAstServiceTypeBuff buff = null;
        List<CFAstServiceTypeBuff> buffList = new LinkedList<CFAstServiceTypeBuff>();
        stmtReadAllBuff = cnx.prepareCall(
                "begin " + schema.getLowerSchemaDbName() + ".rd_svctypeall( ?, ?, ?, ?, ?, ? ) ); end;");
        int argIdx = 1;
        stmtReadAllBuff.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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());
        stmtReadAllBuff.execute();
        resultSet = (ResultSet) stmtReadAllBuff.getObject(1);
        if (resultSet != null) {
            try {
                while (resultSet.next()) {
                    buff = unpackServiceTypeResultSetToBuff(resultSet);
                    buffList.add(buff);
                }
            } catch (SQLException e) {
                // Oracle may return an invalid resultSet if the rowset is empty
            }
        }
        int idx = 0;
        CFAstServiceTypeBuff[] retBuff = new CFAstServiceTypeBuff[buffList.size()];
        Iterator<CFAstServiceTypeBuff> 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;
        }
        if (stmtReadAllBuff != null) {
            try {
                stmtReadAllBuff.close();
            } catch (SQLException e) {
            }
            stmtReadAllBuff = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleServiceTypeTable.java

public CFAstServiceTypeBuff[] readAllBuff(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from ww w  . j  av  a 2  s.com
    ResultSet resultSet = null;
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadAllBuff = null;
    try {
        CFAstServiceTypeBuff buff = null;
        List<CFAstServiceTypeBuff> buffList = new LinkedList<CFAstServiceTypeBuff>();
        stmtReadAllBuff = cnx.prepareCall(
                "begin " + schema.getLowerDbSchemaName() + ".rd_svctypeall( ?, ?, ?, ?, ?, ? ) ); end;");
        int argIdx = 1;
        stmtReadAllBuff.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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());
        stmtReadAllBuff.execute();
        resultSet = (ResultSet) stmtReadAllBuff.getObject(1);
        if (resultSet != null) {
            try {
                while (resultSet.next()) {
                    buff = unpackServiceTypeResultSetToBuff(resultSet);
                    buffList.add(buff);
                }
            } catch (SQLException e) {
                // Oracle may return an invalid resultSet if the rowset is empty
            }
        }
        int idx = 0;
        CFAstServiceTypeBuff[] retBuff = new CFAstServiceTypeBuff[buffList.size()];
        Iterator<CFAstServiceTypeBuff> 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;
        }
        if (stmtReadAllBuff != null) {
            try {
                stmtReadAllBuff.close();
            } catch (SQLException e) {
            }
            stmtReadAllBuff = null;
        }
    }
}

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

public CFSecurityISOCountryBuff readBuffByNameIdx(CFSecurityAuthorization Authorization, String Name) {
    final String S_ProcName = "readBuffByNameIdx";
    ResultSet resultSet = null;// www  . j  av  a 2s.  c o  m
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByNameIdx = null;
    try {
        stmtReadBuffByNameIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".rd_iso_cntrybynameidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByNameIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByNameIdx.setString(argIdx++, Name);
        stmtReadBuffByNameIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByNameIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFSecurityISOCountryBuff buff = unpackISOCountryResultSetToBuff(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) {
            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;
        }
        if (stmtReadBuffByNameIdx != null) {
            try {
                stmtReadBuffByNameIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByNameIdx = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleISOCountryCurrencyTable.java

public void createISOCountryCurrency(CFAccAuthorization Authorization, CFAccISOCountryCurrencyBuff Buff) {
    final String S_ProcName = "createISOCountryCurrency";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  ww  w . jav a 2  s. c  om
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        short ISOCountryId = Buff.getRequiredISOCountryId();
        short ISOCurrencyId = Buff.getRequiredISOCurrencyId();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".crt_iso_cntryccy( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ICCY");
        stmtCreateByPKey.setShort(argIdx++, ISOCountryId);
        stmtCreateByPKey.setShort(argIdx++, ISOCurrencyId);
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_iso_cntryccy() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAccISOCountryCurrencyBuff createdBuff = unpackISOCountryCurrencyResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredISOCountryId(createdBuff.getRequiredISOCountryId());
                Buff.setRequiredISOCurrencyId(createdBuff.getRequiredISOCurrencyId());
                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().newRuntimeException(getClass(), S_ProcName,
                    "crt_iso_cntryccy() did not return a valid result set");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleISOCountryLanguageTable.java

public void createISOCountryLanguage(CFAccAuthorization Authorization, CFAccISOCountryLanguageBuff Buff) {
    final String S_ProcName = "createISOCountryLanguage";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w  w w .j  ava  2  s.com*/
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        short ISOCountryId = Buff.getRequiredISOCountryId();
        short ISOLanguageId = Buff.getRequiredISOLanguageId();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".crt_iso_cntrylng( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ISCL");
        stmtCreateByPKey.setShort(argIdx++, ISOCountryId);
        stmtCreateByPKey.setShort(argIdx++, ISOLanguageId);
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_iso_cntrylng() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAccISOCountryLanguageBuff createdBuff = unpackISOCountryLanguageResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredISOCountryId(createdBuff.getRequiredISOCountryId());
                Buff.setRequiredISOLanguageId(createdBuff.getRequiredISOLanguageId());
                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().newRuntimeException(getClass(), S_ProcName,
                    "crt_iso_cntrylng() did not return a valid result set");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleTagTable.java

public void createTag(CFAccAuthorization Authorization, CFAccTagBuff Buff) {
    final String S_ProcName = "createTag";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w  ww  .j  a va  2 s . com*/
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        String Name = Buff.getRequiredName();
        String Descr = Buff.getOptionalDescr();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".crt_tag( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "CTAG");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setString(argIdx++, Name);
        if (Descr != null) {
            stmtCreateByPKey.setString(argIdx++, Descr);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_tag() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAccTagBuff createdBuff = unpackTagResultSetToBuff(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.setRequiredId(createdBuff.getRequiredId());
                Buff.setRequiredName(createdBuff.getRequiredName());
                Buff.setOptionalDescr(createdBuff.getOptionalDescr());
                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().newRuntimeException(getClass(), S_ProcName,
                    "crt_tag() did not return a valid result set");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
    }
}

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

public void createISOCountryCurrency(CFAstAuthorization Authorization, CFAstISOCountryCurrencyBuff Buff) {
    final String S_ProcName = "createISOCountryCurrency";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from   w  ww . ja  v  a 2s  .  c o m
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        short ISOCountryId = Buff.getRequiredISOCountryId();
        short ISOCurrencyId = Buff.getRequiredISOCurrencyId();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".crt_iso_cntryccy( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ICCY");
        stmtCreateByPKey.setShort(argIdx++, ISOCountryId);
        stmtCreateByPKey.setShort(argIdx++, ISOCurrencyId);
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_iso_cntryccy() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAstISOCountryCurrencyBuff createdBuff = unpackISOCountryCurrencyResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredISOCountryId(createdBuff.getRequiredISOCountryId());
                Buff.setRequiredISOCurrencyId(createdBuff.getRequiredISOCurrencyId());
                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().newRuntimeException(getClass(), S_ProcName,
                    "crt_iso_cntryccy() did not return a valid result set");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
    }
}