Examples of prepareAutoCloseStatement()


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

    @DB
    protected void saveRootDomain() {
        String insertSql = "insert into `cloud`.`domain` (id, name, parent, owner, path, level) values (1, 'ROOT', NULL, 2, '/', 0)";
        Transaction txn = Transaction.currentTxn();
        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
            stmt.executeUpdate();
        } catch (SQLException ex) {
            s_logger.error("error creating ROOT domain", ex);
        }
View Full Code Here

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

    public static String getDatabaseValueString(String selectSql, String name, String errorMsg) {
        Transaction txn = Transaction.open("getDatabaseValueString");
        PreparedStatement stmt = null;

        try {
            stmt = txn.prepareAutoCloseStatement(selectSql);
            ResultSet rs = stmt.executeQuery();
            if (rs.next()) {
                String value = rs.getString(name);
                return value;
            } else {
View Full Code Here

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

    public static long getDatabaseValueLong(String selectSql, String name, String errorMsg) {
        Transaction txn = Transaction.open("getDatabaseValueLong");
        PreparedStatement stmt = null;

        try {
            stmt = txn.prepareAutoCloseStatement(selectSql);
            ResultSet rs = stmt.executeQuery();
            if (rs.next()) {
                return rs.getLong(name);
            } else {
                return -1;
View Full Code Here

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

    }

    public static void saveSQL(String sql, String errorMsg) {
        Transaction txn = Transaction.open("saveSQL");
        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(sql);
            stmt.executeUpdate();
        } catch (SQLException ex) {
            System.out.println("SQL Exception: " + ex.getMessage());
            printError(errorMsg);
        } finally {
View Full Code Here

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

           " LIMIT 0, ?";

        Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setInt(1, maxItems);
            ResultSet rs = pstmt.executeQuery();
            while(rs.next()) {
              SyncQueueItemVO item = new SyncQueueItemVO();
              item.setId(rs.getLong(1));
View Full Code Here

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

      + ", job_result='" + jobResultMessage + "' where job_status=0 AND (job_complete_msid=? OR (job_complete_msid IS NULL AND job_init_msid=?))";
   
        Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setLong(1, msid);
            pstmt.setLong(2, msid);
            pstmt.execute();
        } catch (SQLException e) {
          s_logger.warn("Unable to reset job status for management server " + msid, e);
View Full Code Here

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

                " values(?, ?, ?, ?)";
   
        Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setString(1, syncObjType);
            pstmt.setLong(2, syncObjId);
            pstmt.setString(3, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), dt));
            pstmt.setString(4, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), dt));
            pstmt.execute();
View Full Code Here

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

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

        String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + dcId;
        Transaction txn = Transaction.currentTxn();
        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
            ResultSet rs = stmt.executeQuery();
            while (rs.next()) {
                Long podId = rs.getLong("id");
                String cidrAddress = rs.getString("cidr_address");
                long cidrSize = rs.getLong("cidr_size");
View Full Code Here

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

        String insertVnet = "INSERT INTO `cloud`.`op_dc_vnet_alloc` (vnet, data_center_id, physical_network_id) VALUES ( ?, ?, ?)";

        Transaction txn = Transaction.currentTxn();
        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(insertVnet);
            for (int i = begin; i <= end; i++) {
                stmt.setString(1, Integer.toString(i));
                stmt.setLong(2, dcId);
                stmt.setLong(3, id);
                stmt.addBatch();
View Full Code Here

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

        String insertTraficType = "INSERT INTO `cloud`.`physical_network_traffic_types` " +
                "(physical_network_id, traffic_type, xen_network_label) VALUES ( ?, ?, ?)";

        try {
            PreparedStatement stmt = txn.prepareAutoCloseStatement(insertTraficType);
            for (TrafficType traffic : TrafficType.values()) {
                if(traffic.equals(TrafficType.Control) || traffic.equals(TrafficType.Vpn) ||
                        traffic.equals(TrafficType.None)){
                    continue;
                }
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.