Examples of prepareAutoCloseStatement()


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

        Vector<Long> allZoneIDs = new Vector<Long>();

        String selectSql = "SELECT id FROM data_center";
        Transaction txn = Transaction.currentTxn();
        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
            ResultSet rs = stmt.executeQuery();
            while (rs.next()) {
                Long dcId = rs.getLong("id");
                allZoneIDs.add(dcId);
            }
View Full Code Here

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

        PreparedStatement pstmt = null;
    Transaction txn = Transaction.open(Transaction.CLOUD_DB);
    try {
          try {
              try {
                  pstmt = txn.prepareAutoCloseStatement(String.format("SELECT uuid FROM `%s`", tableName));
                  pstmt.executeQuery();
              } catch (SQLException e) {
                  throw new InvalidParameterValueException("uuid field doesn't exist in table " + tableName);
              }
             
View Full Code Here

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

                  pstmt.executeQuery();
              } catch (SQLException e) {
                  throw new InvalidParameterValueException("uuid field doesn't exist in table " + tableName);
              }
             
              pstmt = txn.prepareAutoCloseStatement(
              String.format("SELECT id FROM `%s` WHERE id=? OR uuid=?", tableName)
             
              // TODO : after graceful period, use following line turn on more secure check
              // String.format("SELECT id FROM %s WHERE (id=? AND uuid IS NULL) OR uuid=?", mapper.entityTableName())
              );
View Full Code Here

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

        try {
            Long domainId = null;
            Long accountId = null;
            //get domainId
            try {
                pstmt = txn.prepareAutoCloseStatement(String.format("SELECT domain_id FROM `%s` WHERE id=?", tableName));
                pstmt.setLong(1, identityId);
                ResultSet rs = pstmt.executeQuery();
                if (rs.next()) {
                    domainId = rs.getLong(1);
                }
View Full Code Here

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

            try {
                String account = "account_id";
                if (resourceType == TaggedResourceType.Project) {
                    account = "project_account_id";
                }
                pstmt = txn.prepareAutoCloseStatement(String.format("SELECT " + account + " FROM `%s` WHERE id=?", tableName));
                pstmt.setLong(1, identityId);
                ResultSet rs = pstmt.executeQuery();
                if (rs.next()) {
                    accountId = rs.getLong(1);
                }
View Full Code Here

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

   
        PreparedStatement pstmt = null;
    Transaction txn = Transaction.open(Transaction.CLOUD_DB);
    try {
          try {
              pstmt = txn.prepareAutoCloseStatement(
                String.format("SELECT uuid FROM `%s` WHERE id=? OR uuid=?", tableName)
              // String.format("SELECT uuid FROM %s WHERE (id=? AND uuid IS NULL) OR uuid=?", tableName)
            );
             
              long id = 0;
View Full Code Here

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

       
        PreparedStatement pstmt = null;
        Transaction txn = Transaction.open(Transaction.CLOUD_DB);
        try {
            try {
                pstmt = txn.prepareAutoCloseStatement(
                    String.format("SELECT id FROM `%s` WHERE uuid IS NULL", tableName)
                );
               
                ResultSet rs = pstmt.executeQuery();
                while(rs.next()) {
View Full Code Here

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

    @DB
    void setInitialUuid(String tableName, long id) throws SQLException {
        Transaction txn = Transaction.currentTxn();
       
        PreparedStatement pstmtUpdate = null;
        pstmtUpdate = txn.prepareAutoCloseStatement(
            String.format("UPDATE `%s` SET uuid=? WHERE id=?", tableName)
        );
       
        pstmtUpdate.setString(1, String.valueOf(id));
        pstmtUpdate.setLong(2, id);
View Full Code Here

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

        String insertSql1 = "INSERT INTO `host` (`id`, `name`, `status` , `type` , `private_ip_address`, `private_netmask` ,`private_mac_address` , `storage_ip_address` ,`storage_netmask`, `storage_mac_address`, `data_center_id`, `version`, `dom0_memory`, `last_ping`, `resource`, `guid`, `hypervisor_type`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String insertSqlHostDetails = "INSERT INTO `host_details` (`id`, `host_id`, `name`, `value`) VALUES(?,?,?,?)";
        String insertSql2 = "INSERT INTO `op_host` (`id`, `sequence`) VALUES(?, ?)";
        Transaction txn = Transaction.currentTxn();
        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql1);
            stmt.setLong(1, 0);
            stmt.setString(2, url);
            stmt.setString(3, "UP");
            stmt.setString(4, "SecondaryStorage");
            stmt.setString(5, "192.168.122.1");
View Full Code Here

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

            }
            stmt.setString(16, url);
            stmt.setString(17, "None");
            stmt.executeUpdate();

            stmt = txn.prepareAutoCloseStatement(insertSqlHostDetails);
            stmt.setLong(1, 1);
            stmt.setLong(2, 1);
            stmt.setString(3, "mount.parent");
            if (nfs) {
                stmt.setString(4, "/mnt");
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.