Package com.cloud.utils.db

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


      Transaction txn = Transaction.open(Transaction.USAGE_DB);
    PreparedStatement pstmt = null;
    try {
        txn.start();
      if (usage.getDeleted() != null) {
        pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
        pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
        pstmt.setLong(2, usage.getAccountId());
        pstmt.setLong(3, usage.getVmInstanceId());
        pstmt.setLong(4, usage.getSecurityGroupId());
      }
View Full Code Here


    HashMap<Long, List<Object>> currentPodCidrSubnets = new HashMap<Long, List<Object>>();

    String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + zoneId +" and removed IS NULL";
    Transaction txn = Transaction.currentTxn();
    try {
    PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
    ResultSet rs = stmt.executeQuery();
    while (rs.next()) {
      Long podId = rs.getLong("id");
      if (podId.longValue() == podIdToSkip) {
                    continue;
View Full Code Here

            String value = detail.getValue();
            if ("password".equals(detail.getKey())) {
                value = DBEncryptionUtil.encrypt(value);
            }
            try {
                PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertOrUpdateSql);
                pstmt.setLong(1, hostId);
                pstmt.setString(2, detail.getKey());
                pstmt.setString(3, value);
                pstmt.setString(4, value);
                pstmt.executeUpdate();
View Full Code Here

      Transaction txn = Transaction.open(Transaction.USAGE_DB);
    PreparedStatement pstmt = null;
    try {
        txn.start();
      if (usage.getDeleted() != null) {
        pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
        pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
        pstmt.setLong(2, usage.getAccountId());
        pstmt.setLong(3, usage.getUserId());
      }
      pstmt.executeUpdate();
View Full Code Here

        Transaction txn = Transaction.open(Transaction.USAGE_DB);
        PreparedStatement pstmt = null;

        try {
            int i = 1;
            pstmt = txn.prepareAutoCloseStatement(sql);
            if (param1 != null) {
                pstmt.setLong(i++, param1);
            }
            pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), startDate));
            pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), endDate));
View Full Code Here

  @Override
    public void invalidateRunSession(long id, long runid) {
      Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            pstmt = txn.prepareAutoCloseStatement("update mshost set runid=0, state='Down' where id=? and runid=?");
            pstmt.setLong(1, id);
            pstmt.setLong(2, runid);
           
            pstmt.executeUpdate();
        } catch (SQLException e) {
View Full Code Here

        Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            txn.start();
           
            pstmt = txn.prepareAutoCloseStatement("update mshost set name=?, version=?, service_ip=?, service_port=?, last_update=?, removed=null, alert_count=0, runid=?, state=? where id=?");
            pstmt.setString(1, name);
            pstmt.setString(2, version);
            pstmt.setString(3, serviceIP);
            pstmt.setInt(4, servicePort);
            pstmt.setString(5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), lastUpdate));
View Full Code Here

        Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            txn.start();
           
            pstmt = txn.prepareAutoCloseStatement("update mshost set last_update=?, removed=null, alert_count=0 where id=? and runid=?");
            pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), lastUpdate));
            pstmt.setLong(2, id);
            pstmt.setLong(3, runid);
           
            int count = pstmt.executeUpdate();
View Full Code Here

        PreparedStatement pstmt = null;
        int changedRows = 0;
        try {
            txn.start();
           
            pstmt = txn.prepareAutoCloseStatement("update mshost set alert_count=alert_count+1 where id=? and alert_count=0");
            pstmt.setLong(1, id);
           
            changedRows = pstmt.executeUpdate();
            txn.commit();
        } catch(Exception e) {
View Full Code Here

  @Override
    public void update(long id, long runId, State state, Date lastUpdate) {
      Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            pstmt = txn.prepareAutoCloseStatement("update mshost set state=?, last_update=? where id=? and runid=?");
            pstmt.setString(1, state.toString());
            pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), lastUpdate));
            pstmt.setLong(3, id);
            pstmt.setLong(4, runId);
           
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.