Package GenericDBMS

Examples of GenericDBMS.DBConnectionManager


        TextNullable title3 = null;
        int numCustomers = 0;
        IntegerData numStocks = null;
        double totalValue = 0;

        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // select 
        //     'Customers',
        //     count(distinct CustomerName),
        //     'Stocks',
        //     count(distinct StockName),
        //     'Total value',
        //     sum(Price*Quantity)
        // into
        //     :title1,
        //     :numCustomers,
        //     :title2,
        //     :numStocks,
        //     :title3,
        //     :totalValue
        // from Holding
        // on session DBConnection
        // -- ============================================
        String qq_SQL = "select " +
                        "'Customers', " +
                        "count(distinct CustomerName), " +
                        "'Stocks', " +
                        "count(distinct StockName), " +
                        "'Total value', " +
                        "sum(Price*Quantity) " +
                        "from Holding ";
        final ParameterHolder qqh_title1 = new ParameterHolder(title1);
        final ParameterHolder qqh_numCustomers = new ParameterHolder(numCustomers);
        final ParameterHolder qqh_title2 = new ParameterHolder(title2);
        final ParameterHolder qqh_numStocks = new ParameterHolder(numStocks);
        final ParameterHolder qqh_title3 = new ParameterHolder(title3);
        final ParameterHolder qqh_totalValue = new ParameterHolder(totalValue);
        RowCountCallbackHandler qq_RowCounter = new RowCountCallbackHandler() {
            protected void processRow(ResultSet pResultSet, int pRow) throws SQLException {
                if (pRow >= 1) {
                    throw new IncorrectResultSizeDataAccessException(1, pRow+1);
                }
                ResultSetHelper helper = new ResultSetHelper(pResultSet);
                qqh_title1.setObject(helper.getString(1));
                qqh_numCustomers.setInt(helper.getInt(2));
                qqh_title2.setObject(helper.getTextData(3));
                qqh_numStocks.setObject(helper.getIntegerData(4));
                qqh_title3.setObject(helper.getTextNullable(5));
                qqh_totalValue.setDouble(helper.getDouble(6));
            }
        };
        dBConnection.getTemplate().query(qq_SQL, qq_RowCounter);
        title1 = (String)qqh_title1.getObject();
        numCustomers = qqh_numCustomers.getInt();
        title2 = (TextData)qqh_title2.getObject();
        numStocks = (IntegerData)qqh_numStocks.getObject();
        title3 = (TextNullable)qqh_title3.getObject();
View Full Code Here


     * self.StockNameList[8] = new;<br>
     * self.StockNameList[8].TextValue.Setvalue('Forte');<br>
     * <p>
     */
    private void setupStockNameList() {
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
        ResultSet qq_rs = null;
        PreparedStatement qq_cmd = null;
        String qq_SQL = null;
        try {

            // -- =============== Original SQL ===============
            // select StockName from Stock
            //         on session DBConnection
            // -- ============================================
            qq_SQL = "select StockName from Stock ";
            qq_cmd = dBConnection.getPreparedStatement(qq_SQL);
            qq_rs = qq_cmd.executeQuery();
            ResultSetHelper qq_rsHelper = new ResultSetHelper(qq_rs);
            while (qq_rsHelper.next()) {
                TextData temp = qq_rsHelper.getTextData(1);
                ListElement row = new ListElement();
                row.getTextValue().setValue( temp.getValue() );
                this.stockNameList.add(row);
            }
        }
        catch (SQLException qq_error) {
            throw new SQLErrorCodeSQLExceptionTranslator(dBConnection.getDataSource()).translate("Running SQL", qq_SQL, qq_error);
        }
        finally {
            dBConnection.cleanup(qq_cmd);
        }
    }
View Full Code Here

     * SQLDeleteHolding<p>
     * <p>
     * @param pHolding Type: Holding
     */
    private void SQLDeleteHolding(Holding pHolding) {
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // delete from Holding
        // where CustomerName=:pHolding.CustomerName and
        //    StockName=:pHolding.StockName
        // on session DBConnection
        // -- ============================================
        String qq_SQL = "delete from Holding " +
                        "where CustomerName=? and " +
                        "StockName=? ";
        Object[] qq_SQLParams = new Object[] {
            pHolding.getCustomerName(),
            pHolding.getStockName()
        };
        dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
    }
View Full Code Here

     * SQLInsertHolding<p>
     * <p>
     * @param pHolding Type: Holding
     */
    private void SQLInsertHolding(Holding pHolding) {
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // insert into Holding (CustomerName, StockName, Quantity, Price)
        // values (:pHolding.CustomerName, :pHolding.StockName,
        //        :pHolding.Quantity, :pHolding.Price)
        // on session DBConnection
        // -- ============================================
        String qq_SQL = "insert into Holding (CustomerName, StockName, Quantity, Price) " +
                        "values (?, ?, " +
                        "?, ?) ";
        Object[] qq_SQLParams = new Object[] {
            pHolding.getCustomerName(),
            pHolding.getStockName(),
            new Integer(pHolding.getQuantity()),
            new Float(pHolding.getPrice())
        };
        dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
    }
View Full Code Here

     */
    private Customer SQLSelectCustomer(TextData pName) {
        Customer aCustomer = new Customer();
        int recsReturned = 0;
        int qq_RowCount = 0;
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // select * into :aCustomer from Customer
        //         where CustomerName = :pName
        //         on session DBConnection
        // -- ============================================
        String qq_SQL = "select *  from Customer " +
                        "where CustomerName = ? ";
        Object[] qq_SQLParams = new Object[] {pName };
        // TODO [112,Info]: Using the * in a query rather than explicitly enumerating the column list is often inefficient.
        JdbcTemplate qq_Template = dBConnection.getTemplate();
        List qq_List = qq_Template.query(qq_SQL, qq_SQLParams, new BeanRowMapper(aCustomer, Customer.class));
        if (!qq_List.isEmpty()) {
            aCustomer = (Customer)DataAccessUtils.singleResult(qq_List);
        }
        qq_RowCount = qq_List.size();
View Full Code Here

     */
    private Holding SQLSelectHolding(TextData pSelHoldCustName, String pSelHoldStockName) {
        Holding aHolding = new Holding();
        int recsReturned = 0;
        int qq_RowCount = 0;
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // select * into :aHolding from Holding
        //           where CustomerName = :pSelHoldCustName
        //           and StockName = :pSelHoldStockName
        //           on session DBConnection
        // -- ============================================
        String qq_SQL = "select *  from Holding " +
                        "where CustomerName = ? " +
                        "and StockName = ? ";
        Object[] qq_SQLParams = new Object[] {
            pSelHoldCustName,
            pSelHoldStockName
        };
        // TODO [112,Info]: Using the * in a query rather than explicitly enumerating the column list is often inefficient.
        JdbcTemplate qq_Template = dBConnection.getTemplate();
        List qq_List = qq_Template.query(qq_SQL, qq_SQLParams, new BeanRowMapper(aHolding, Holding.class));
        if (!qq_List.isEmpty()) {
            aHolding = (Holding)DataAccessUtils.singleResult(qq_List);
        }
        qq_RowCount = qq_List.size();
View Full Code Here

     * @return Array_Of_Holding<Holding>
     */
    private Array_Of_Holding<Holding> SQLSelectHoldingList(TextData pName) {
        Array_Of_Holding<Holding> aCustomersHoldingList = new Array_Of_Holding<Holding>();

        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // select * into :aCustomersHoldingList
        // from Holding
        // where CustomerName = :pName
        // on session DBConnection
        // -- ============================================
        String qq_SQL = "select * " +
                        "from Holding " +
                        "where CustomerName = ? ";
        Object[] qq_SQLParams = new Object[] {pName };
        // TODO [112,Info]: Using the * in a query rather than explicitly enumerating the column list is often inefficient.
        JdbcTemplate qq_Template = dBConnection.getTemplate();
        aCustomersHoldingList = (Array_Of_Holding)qq_Template.query(qq_SQL, qq_SQLParams, new ArrayRowMapper(aCustomersHoldingList, Array_Of_Holding.class));

        return aCustomersHoldingList;
    }
View Full Code Here

     * <p>
     * @param pCustomerName Type: TextData
     * @param pCashBalance Type: float
     */
    public void SQLUpdateCashBal(TextData pCustomerName, float pCashBalance) {
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // update Customer
        // set CashBalance = :pCashBalance
        // where CustomerName = :pCustomerName
        // on session DBConnection
        // -- ============================================
        String qq_SQL = "update Customer " +
                        "set CashBalance = ? " +
                        "where CustomerName = ? ";
        Object[] qq_SQLParams = new Object[] {
            new Float(pCashBalance),
            pCustomerName
        };
        dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
    }
View Full Code Here

     * SQLUpdateHolding<p>
     * <p>
     * @param pHolding Type: Holding
     */
    private void SQLUpdateHolding(Holding pHolding) {
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");

        // -- =============== Original SQL ===============
        // update Holding set Quantity = :pHolding.Quantity
        // where CustomerName=:pHolding.CustomerName and
        // StockName=:pHolding.StockName
        // on session DBConnection
        // -- ============================================
        String qq_SQL = "update Holding set Quantity = ? " +
                        "where CustomerName=? and " +
                        "StockName=? ";
        Object[] qq_SQLParams = new Object[] {
            new Integer(pHolding.getQuantity()),
            pHolding.getCustomerName(),
            pHolding.getStockName()
        };
        dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
    }
View Full Code Here

     * self.StockNameList[8] = new;<br>
     * self.StockNameList[8].TextValue.Setvalue('Forte');<br>
     * <p>
     */
    private void setupStockNameList() {
        DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
        ResultSet qq_rs = null;
        PreparedStatement qq_cmd = null;
        String qq_SQL = null;
        try {

            // -- =============== Original SQL ===============
            // select StockName from Stock
            //         on session DBConnection
            // -- ============================================
            qq_SQL = "select StockName from Stock ";
            qq_cmd = dBConnection.getPreparedStatement(qq_SQL);
            qq_rs = qq_cmd.executeQuery();
            ResultSetHelper qq_rsHelper = new ResultSetHelper(qq_rs);
            while (qq_rsHelper.next()) {
                TextData temp = qq_rsHelper.getTextData(1);
                ListElement row = new ListElement();
                row.getTextValue().setValue( temp.getValue() );
                this.stockNameList.add(row);
            }
        }
        catch (SQLException qq_error) {
            throw new SQLErrorCodeSQLExceptionTranslator(dBConnection.getDataSource()).translate("Running SQL", qq_SQL, qq_error);
        }
        finally {
            dBConnection.cleanup(qq_cmd);
        }
    }
View Full Code Here

TOP

Related Classes of GenericDBMS.DBConnectionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.