Package com.cloud.utils.db

Examples of com.cloud.utils.db.Transaction.prepareStatement()


        PreparedStatement pstmt = null;
        List<EngineHostVO> result = new ArrayList<EngineHostVO>();
        ResultSet rs = null;
        try {
            String sql = "select h.id from host h left join  cluster c on h.cluster_id=c.id where h.mgmt_server_id is not null and h.last_ping < ? and h.status in ('Up', 'Updating', 'Disconnected', 'Connecting') and h.type not in ('ExternalFirewall', 'ExternalLoadBalancer', 'TrafficMonitor', 'SecondaryStorage', 'LocalSecondaryStorage', 'L2Networking') and (h.cluster_id is null or c.managed_state = 'Managed') ;" ;
            pstmt = txn.prepareStatement(sql);
            pstmt.setLong(1, timeout);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                long id = rs.getLong(1); //ID column
                result.add(findById(id));
View Full Code Here


        ResultSet rs = null;
        HostVO host = null;
        Transaction txn = Transaction.currentTxn();

        try {
            pstmt = txn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                long id = rs.getLong(1);
                host = hostDao.findById(id);
            }
View Full Code Here

            } else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
                return templateZonePairList;
            }

            sql += joinClause + whereClause + getOrderByLimit(pageSize, startIndex);
            pstmt = txn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                Pair<Long, Long> templateZonePair = new Pair<Long, Long>(rs.getLong(1), -1L);
                templateZonePairList.add(templateZonePair);
            }
View Full Code Here

                whereClause += " AND ";
            }

            sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso, bootable, hyperType, zoneId, onlyReady, showDomr) + groupByClause + getOrderByLimit(pageSize, startIndex);

            pstmt = txn.prepareStatement(sql);
            rs = pstmt.executeQuery();

            while (rs.next()) {
                Pair<Long, Long> templateZonePair = new Pair<Long, Long>(rs.getLong(1), rs.getLong(2));
                templateZonePairList.add(templateZonePair);
View Full Code Here

            } else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
                return templateZonePairList;
            }

            sql += joinClause + whereClause + getOrderByLimit(pageSize, startIndex);
            pstmt = txn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                Pair<Long, Long> templateZonePair = new Pair<Long, Long>(rs.getLong(1), -1L);
                templateZonePairList.add(templateZonePair);
            }
View Full Code Here

            }
           
            sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso, bootable, hyperType, zoneId,
                    onlyReady, showDomr) + groupByClause + getOrderByLimit(pageSize, startIndex);

            pstmt = txn.prepareStatement(sql);
            rs = pstmt.executeQuery();

            while (rs.next()) {
               Pair<Long, Long> templateZonePair = new Pair<Long, Long>(rs.getLong(1), rs.getLong(2));
                               templateZonePairList.add(templateZonePair);
View Full Code Here

            final StringBuilder sql = new StringBuilder(SELECT_TEMPLATE_S3_REF);
            sql.append(joinClause);
            sql.append(whereClause);
            sql.append(getOrderByLimit(pageSize, startIndex));

            pstmt = txn.prepareStatement(sql.toString());
            rs = pstmt.executeQuery();
            while (rs.next()) {
                final Pair<Long, Long> templateZonePair = new Pair<Long, Long>(
                        rs.getLong(1), -1L);
                templateZonePairList.add(templateZonePair);
View Full Code Here

        PreparedStatement pstmt = null;
        List<StoragePoolHostVO> result = new ArrayList<StoragePoolHostVO>();
        ResultSet rs = null;
        try {
            String sql = HOST_FOR_POOL_SEARCH;
            pstmt = txn.prepareStatement(sql);

            pstmt.setLong(1, poolId);
            pstmt.setString(2, hostStatus.toString());
            rs = pstmt.executeQuery();
            while (rs.next()) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.