Package com.cloud.utils.db

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


    public long getLastJobSuccessDateMillis() {
        Transaction txn = Transaction.currentTxn();
        PreparedStatement pstmt = null;
        String sql = GET_LAST_JOB_SUCCESS_DATE_MILLIS;
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            ResultSet rs = pstmt.executeQuery();
            if (rs.next()) {
                return rs.getLong(1);
            }
        } catch (Exception ex) {
View Full Code Here


      Transaction txn = Transaction.open(Transaction.USAGE_DB);
    PreparedStatement pstmt = null;
    try {
        txn.start();
      String sql = REMOVE_BY_USERID_STORAGEID;
      pstmt = txn.prepareAutoCloseStatement(sql);
      pstmt.setLong(1, accountId);
      pstmt.setLong(2, volId);
      pstmt.setInt(3, storage_type);
      pstmt.executeUpdate();
      txn.commit();
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.getId());
        pstmt.setInt(4, usage.getStorageType());
      }
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

  public Map<String, UsageNetworkVO> getRecentNetworkStats() {
        Transaction txn = Transaction.open(Transaction.USAGE_DB);
        String sql = SELECT_LATEST_STATS;
        PreparedStatement pstmt = null;
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            ResultSet rs = pstmt.executeQuery();
            Map<String, UsageNetworkVO> returnMap = new HashMap<String, UsageNetworkVO>();
            while (rs.next()) {
                long accountId = rs.getLong(1);
                long zoneId = rs.getLong(2);
View Full Code Here

        Transaction txn = Transaction.currentTxn();
        String sql = DELETE_OLD_STATS;
        PreparedStatement pstmt = null;
        try {
            txn.start();
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setLong(1, maxEventTime);
            pstmt.executeUpdate();
            txn.commit();
        } catch (Exception ex) {
            txn.rollback();
View Full Code Here

        Transaction txn = Transaction.currentTxn();
        try {
            txn.start();
            String sql = INSERT_USAGE_NETWORK;
            PreparedStatement pstmt = null;
            pstmt = txn.prepareAutoCloseStatement(sql); // in reality I just want CLOUD_USAGE dataSource connection
            for (UsageNetworkVO usageNetwork : usageNetworks) {
                pstmt.setLong(1, usageNetwork.getAccountId());
                pstmt.setLong(2, usageNetwork.getZoneId());
                pstmt.setLong(3, usageNetwork.getHostId());
                pstmt.setString(4, usageNetwork.getHostType());
View Full Code Here

      Transaction txn = Transaction.open(Transaction.USAGE_DB);
    PreparedStatement pstmt = null;
    try {
        txn.start();
      String sql = REMOVE_BY_USERID_VOLID;
      pstmt = txn.prepareAutoCloseStatement(sql);
      pstmt.setLong(1, accountId);
      pstmt.setLong(2, volId);
      pstmt.executeUpdate();
      txn.commit();
    } catch (Exception e) {
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.getId());
      }
      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

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.