当前位置: 首页>>代码示例>>Java>>正文


Java DbUtils.close方法代码示例

本文整理汇总了Java中nxt.util.DbUtils.close方法的典型用法代码示例。如果您正苦于以下问题:Java DbUtils.close方法的具体用法?Java DbUtils.close怎么用?Java DbUtils.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nxt.util.DbUtils的用法示例。


在下文中一共展示了DbUtils.close方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransactionIterator

import nxt.util.DbUtils; //导入方法依赖的package包/类
public static DbIterator<? extends Transaction> getTransactionIterator(
    Long accountId, TransactionType[] recipientTypes,
    TransactionType[] senderTypes, int timestamp, Boolean orderAscending,
    Object referencedTransaction) {
  Connection con = null;
  try {
    con = Db.getConnection();
    PreparedStatement pstmt = createTransactionStatement(con, accountId,
        recipientTypes, senderTypes, timestamp, orderAscending,
        referencedTransaction, false);

    DbIterator<? extends Transaction> iterator = Nxt.getBlockchain()
        .getTransactions(con, pstmt);
    return iterator;
  }
  catch (SQLException e) {
    logger.error("SQL Error", e);
    if (con != null) {
      DbUtils.close(con);
    }
  }
  return null;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:24,代码来源:TransactionDB.java

示例2: getGeneratedBlocks

import nxt.util.DbUtils; //导入方法依赖的package包/类
public static List<Block> getGeneratedBlocks(Long accountId) {
  Connection con = null;
  try {
    con = Db.getConnection();
    PreparedStatement pstmt = con
        .prepareStatement("SELECT * FROM block WHERE generator_id = ? ORDER BY db_id ASC");
    pstmt.setLong(1, accountId);

    List<Block> result = new ArrayList<Block>();
    DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(con,
        pstmt);
    while (iterator.hasNext()) {
      result.add(iterator.next());
    }
    return result;
  }
  catch (SQLException e) {
    DbUtils.close(con);
    throw new RuntimeException(e.toString(), e);
  }
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:22,代码来源:BlockDB.java

示例3: getAllBlocks

import nxt.util.DbUtils; //导入方法依赖的package包/类
public DbIterator<BlockImpl> getAllBlocks()
{
  Connection localConnection = null;
  try
  {
    localConnection = Db.getConnection();
    PreparedStatement localPreparedStatement = localConnection.prepareStatement("SELECT * FROM block ORDER BY db_id ASC");
    new DbIterator(localConnection, localPreparedStatement, new DbIterator.ResultSetReader()
    {
      public BlockImpl get(Connection paramAnonymousConnection, ResultSet paramAnonymousResultSet)
        throws NxtException.ValidationException
      {
        return BlockDb.findBlock(paramAnonymousConnection, paramAnonymousResultSet);
      }
    });
  }
  catch (SQLException localSQLException)
  {
    DbUtils.close(new AutoCloseable[] { localConnection });
    throw new RuntimeException(localSQLException.toString(), localSQLException);
  }
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:23,代码来源:BlockchainImpl.java

示例4: getAllTransactions

import nxt.util.DbUtils; //导入方法依赖的package包/类
public DbIterator<TransactionImpl> getAllTransactions()
{
  Connection localConnection = null;
  try
  {
    localConnection = Db.getConnection();
    PreparedStatement localPreparedStatement = localConnection.prepareStatement("SELECT * FROM transaction ORDER BY db_id ASC");
    new DbIterator(localConnection, localPreparedStatement, new DbIterator.ResultSetReader()
    {
      public TransactionImpl get(Connection paramAnonymousConnection, ResultSet paramAnonymousResultSet)
        throws NxtException.ValidationException
      {
        return TransactionDb.findTransaction(paramAnonymousConnection, paramAnonymousResultSet);
      }
    });
  }
  catch (SQLException localSQLException)
  {
    DbUtils.close(new AutoCloseable[] { localConnection });
    throw new RuntimeException(localSQLException.toString(), localSQLException);
  }
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:23,代码来源:BlockchainImpl.java

示例5: getTransactions

import nxt.util.DbUtils; //导入方法依赖的package包/类
public static LazyList getTransactions(Boolean orderAscending, INxtService nxt) {
  Connection con = null;

  /* Count number of records */
  int available = Nxt.getBlockchain().getTransactionCount();

  /* Create the record iterator */
  try {
    con = Db.getConnection();
    StringBuilder buf = new StringBuilder();
    buf.append("SELECT * FROM transaction ");
    if (orderAscending != null) {
      if (Boolean.TRUE.equals(orderAscending)) {
        buf.append("ORDER BY db_id ASC");
      }
      else if (Boolean.FALSE.equals(orderAscending)) {
        buf.append("ORDER BY db_id DESC");
      }
    }
    PreparedStatement pstmt = con.prepareStatement(buf.toString());
    DbIterator<? extends Transaction> iterator = Nxt.getBlockchain()
        .getTransactions(con, pstmt);
    LazyList lazyList = new LazyList(iterator, available, nxt);
    return lazyList;
  }
  catch (SQLException e) {
    logger.error("SQL Error", e);
    if (con != null) {
      DbUtils.close(con);
    }
  }
  return null;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:34,代码来源:TransactionDB.java

示例6: getBlocks

import nxt.util.DbUtils; //导入方法依赖的package包/类
public static LazyList getBlocks(Boolean orderAscending, INxtService nxt) {
  Connection con = null;

  /* Count number of records */
  // int available = nxt.getSmartBlockCount();
  int available = Nxt.getBlockchain().getBlockCount();

  /* Create the record iterator */
  try {
    con = Db.getConnection();
    StringBuilder buf = new StringBuilder();
    buf.append("SELECT * FROM block ");
    if (orderAscending != null) {
      if (Boolean.TRUE.equals(orderAscending)) {
        buf.append("ORDER BY db_id ASC");
      }
      else if (Boolean.FALSE.equals(orderAscending)) {
        buf.append("ORDER BY db_id DESC");
      }
    }
    PreparedStatement pstmt = con.prepareStatement(buf.toString());
    DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(con,
        pstmt);
    LazyList lazyList = new LazyList(iterator, available);
    return lazyList;
  }
  catch (SQLException e) {
    logger.error("SQL Error", e);
    if (con != null) {
      DbUtils.close(con);
    }
  }
  return null;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:35,代码来源:BlockDB.java

示例7: getAllBlocks

import nxt.util.DbUtils; //导入方法依赖的package包/类
@Override
public DbIterator<BlockImpl> getAllBlocks() {
    Connection con = null;
    try {
        con = Db.getConnection();
        PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block ORDER BY db_id ASC");
        return getBlocks(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:13,代码来源:BlockchainImpl.java

示例8: getBlocks

import nxt.util.DbUtils; //导入方法依赖的package包/类
@Override
public DbIterator<BlockImpl> getBlocks(Account account, int timestamp) {
    Connection con = null;
    try {
        con = Db.getConnection();
        PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block WHERE timestamp >= ? AND generator_id = ? ORDER BY db_id ASC");
        pstmt.setInt(1, timestamp);
        pstmt.setLong(2, account.getId());
        return getBlocks(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:15,代码来源:BlockchainImpl.java

示例9: getAllTransactions

import nxt.util.DbUtils; //导入方法依赖的package包/类
@Override
public DbIterator<TransactionImpl> getAllTransactions() {
    Connection con = null;
    try {
        con = Db.getConnection();
        PreparedStatement pstmt = con.prepareStatement("SELECT * FROM transaction ORDER BY db_id ASC");
        return getTransactions(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:13,代码来源:BlockchainImpl.java

示例10: getTransactions

import nxt.util.DbUtils; //导入方法依赖的package包/类
@Override
public DbIterator<TransactionImpl> getTransactions(Account account, byte type, byte subtype, int timestamp, Boolean orderAscending) {
    Connection con = null;
    try {
        StringBuilder buf = new StringBuilder();
        if (orderAscending != null) {
            buf.append("SELECT * FROM (");
        }
        buf.append("SELECT * FROM transaction WHERE recipient_id = ? ");
        if (timestamp > 0) {
            buf.append("AND timestamp >= ? ");
        }
        if (type >= 0) {
            buf.append("AND type = ? ");
            if (subtype >= 0) {
                buf.append("AND subtype = ? ");
            }
        }
        buf.append("UNION SELECT * FROM transaction WHERE sender_id = ? ");
        if (timestamp > 0) {
            buf.append("AND timestamp >= ? ");
        }
        if (type >= 0) {
            buf.append("AND type = ? ");
            if (subtype >= 0) {
                buf.append("AND subtype = ? ");
            }
        }
        if (Boolean.TRUE.equals(orderAscending)) {
            buf.append(") ORDER BY timestamp ASC");
        } else if (Boolean.FALSE.equals(orderAscending)) {
            buf.append(") ORDER BY timestamp DESC");
        }
        con = Db.getConnection();
        PreparedStatement pstmt;
        int i = 0;
        pstmt = con.prepareStatement(buf.toString());
        pstmt.setLong(++i, account.getId());
        if (timestamp > 0) {
            pstmt.setInt(++i, timestamp);
        }
        if (type >= 0) {
            pstmt.setByte(++i, type);
            if (subtype >= 0) {
                pstmt.setByte(++i, subtype);
            }
        }
        pstmt.setLong(++i, account.getId());
        if (timestamp > 0) {
            pstmt.setInt(++i, timestamp);
        }
        if (type >= 0) {
            pstmt.setByte(++i, type);
            if (subtype >= 0) {
                pstmt.setByte(++i, subtype);
            }
        }
        return getTransactions(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:64,代码来源:BlockchainImpl.java


注:本文中的nxt.util.DbUtils.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。