Package com.cloud.utils.db

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


                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


            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

            }


            if (curr_index < userVmDataList.size()){
                int batch_size = (userVmDataList.size() - curr_index);
                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++){
                    pstmt.setLong(k, userVmDataList.get(j).getId());
                }
                ResultSet rs = pstmt.executeQuery();
View Full Code Here

        PreparedStatement pstmt = null;
        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

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

        try {
            pstmt = txn.prepareStatement(sql);
            pstmt.setLong(1, poolId);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                long id = rs.getLong(1);
                host = hostDao.findById(id);
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

    PreparedStatement pstmt = null;
    List<VMTemplateHostVO> result = new ArrayList<VMTemplateHostVO>();
    ResultSet rs = null;
    try {
      String sql = DOWNLOADS_STATE_DC_POD;
      pstmt = txn.prepareStatement(sql);
     
      pstmt.setLong(1, datacenterId);
      pstmt.setLong(2, podId);
      pstmt.setLong(3, templateId);
      pstmt.setString(4, downloadState.toString());
View Full Code Here

        PreparedStatement pstmt = null;
        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<VMTemplateStoragePoolVO> result = new ArrayList<VMTemplateStoragePoolVO>();
    ResultSet rs = null;
    try {
      String sql = DOWNLOADS_STATE_DC_POD;
      pstmt = txn.prepareStatement(sql);
     
      pstmt.setLong(1, datacenterId);
      pstmt.setLong(2, podId);
      pstmt.setLong(3, templateId);
      pstmt.setString(4, downloadState.toString());
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.