Package com.cloud.utils.db

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


        // TODO: We should fix this.  We shouldn't be crossing daos in a dao code.
        List<Long> standaloneList = new ArrayList<Long>();
        TransactionLegacy txn = TransactionLegacy.currentTxn();
        String sql = "SELECT job_id FROM async_job_join_map WHERE join_job_id = ? AND job_id NOT IN (SELECT content_id FROM sync_queue_item)";
        try {
            PreparedStatement pstmt = txn.prepareStatement(sql);
            pstmt.setLong(1, joinedJobId);
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                standaloneList.add(rs.getLong(1));
            }
View Full Code Here


    public List<Long> findJobsToWakeBetween(Date cutDate) {
        List<Long> standaloneList = new ArrayList<Long>();
        TransactionLegacy txn = TransactionLegacy.currentTxn();
        try {
            String sql = "SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ? AND job_id NOT IN (SELECT content_id FROM sync_queue_item)";
            PreparedStatement pstmt = txn.prepareStatement(sql);
            pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate));
            pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate));
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                standaloneList.add(rs.getLong(1));
View Full Code Here

                standaloneList.add(rs.getLong(1));
            }

            // update for next wake-up
            sql = "UPDATE async_job_join_map SET next_wakeup=DATE_ADD(next_wakeup, INTERVAL wakeup_interval SECOND) WHERE next_wakeup < ? AND expiration > ?";
            pstmt = txn.prepareStatement(sql);
            pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate));
            pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate));
            pstmt.executeUpdate();

            return standaloneList;
View Full Code Here

    public List<Long> listPodIdsHavingVmsforAccount(long zoneId, long accountId) {
        TransactionLegacy txn = TransactionLegacy.currentTxn();
        List<Long> result = new ArrayList<Long>();
        String sql = LIST_PODS_HAVING_VMS_FOR_ACCOUNT;

        try(PreparedStatement pstmt = txn.prepareStatement(sql)) {
            pstmt.setLong(1, zoneId);
            pstmt.setLong(2, accountId);
            try(ResultSet rs = pstmt.executeQuery();)
            {
                while (rs.next()) {
View Full Code Here

        try {
            int curr_index = 0;
            List<UserVmData> userVmDataList = new ArrayList(userVmDataHash.values());
            if (userVmDataList.size() > VM_DETAILS_BATCH_SIZE)
            {
                try (PreparedStatement pstmt = txn.prepareStatement(VM_DETAILS + getQueryBatchAppender(VM_DETAILS_BATCH_SIZE));)
                {
                    while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmDataList.size()) {
                        // set the vars value
                        for (int k = 1, j = curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
                            pstmt.setLong(k, userVmDataList.get(j).getId());
View Full Code Here

                }
            }

            if (curr_index < userVmDataList.size()) {
                int batch_size = (userVmDataList.size() - curr_index);
                try (PreparedStatement vm_details_pstmt = txn.prepareStatement(VM_DETAILS + getQueryBatchAppender(batch_size)))
                {
                    // set the vars value
                    for (int k = 1, j = curr_index; j < curr_index + batch_size; j++, k++) {
                        vm_details_pstmt.setLong(k, userVmDataList.get(j).getId());
                    }
View Full Code Here

        try {
            txn.start();

            while (startIP <= endIP) {
                stmt = txn.prepareStatement(insertSql);
                stmt.setString(1, NetUtils.long2Ip(startIP++));
                stmt.setLong(2, dcId);
                stmt.setLong(3, podId);
                stmt.setLong(4, dcId);
                stmt.executeUpdate();
View Full Code Here

                stmt.setLong(2, dcId);
                stmt.setLong(3, podId);
                stmt.setLong(4, dcId);
                stmt.executeUpdate();
                stmt.close();
                stmt = txn.prepareStatement(updateSql);
                stmt.setLong(1, dcId);
                stmt.executeUpdate();
                stmt.close();
            }
            txn.commit();
View Full Code Here

        List<HostVO> result = new ArrayList<HostVO>();
        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

        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.