Package com.cloud.utils.db

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


    PreparedStatement pstmt = null;
    List<VMTemplateStoragePoolVO> result = new ArrayList<VMTemplateStoragePoolVO>();
    ResultSet rs = null;
    try {
      String sql = HOST_TEMPLATE_SEARCH;
      pstmt = txn.prepareStatement(sql);
     
      pstmt.setLong(1, hostId);
      pstmt.setLong(2, templateId);
      rs = pstmt.executeQuery();
      while (rs.next()) {
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

        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

       
        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

      Transaction txn = Transaction.open(Transaction.CLOUD_DB);
      txn.start();
    try {
        String request = "SELECT vm.id, uservm.account_id, vm.group from vm_instance vm, user_vm uservm where vm.group is not null and vm.removed is null and vm.id=uservm.id order by id";
        System.out.println(request);
        PreparedStatement statement = txn.prepareStatement(request);
        ResultSet result = statement.executeQuery();
        while (result.next()) {
          vmId = result.getLong(1);
          accountId = result.getLong(2);
          groupName = result.getString(3);
View Full Code Here

    //Use update method with category instead
    @Override @Deprecated
    public boolean update(String name, String value) {
      Transaction txn = Transaction.currentTxn();
    try {
      PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
      stmt.setString(1, value);
      stmt.setString(2, name);
      stmt.executeUpdate();
      return true;
    } catch (Exception e) {
View Full Code Here

    @Override
    public boolean update(String name, String category, String value) {
      Transaction txn = Transaction.currentTxn();
    try {
      value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value;
      PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
      stmt.setString(1, value);
      stmt.setString(2, name);
      stmt.executeUpdate();
      return true;
    } catch (Exception e) {
View Full Code Here

            int curr_index=0;
           
            List<UserVmData> userVmDataList = new ArrayList(userVmDataHash.values());
           
            if (userVmDataList.size() > VM_DETAILS_BATCH_SIZE){
                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

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.