Exemplo n.º 1
0
  public boolean create(LoginHistoryVo loginHistory) throws SQLException {

    Connection conn = null;
    String sqlQuery = "";
    PreparedStatement prepStmt = null;
    ResultSet rs = null;

    try {
      conn = wcareConnector.getConnectionFromPool();
      sqlQuery =
          "INSERT INTO TBL_LOGIN_HISTORY(S_LOGIN_HISTORY_ID,S_TRANSACTION_ID,"
              + "S_USER_ID,S_IP_ADDRESS,S_HOST)"
              + "values(?, ?, ?, ?, ?)";

      prepStmt = conn.prepareStatement(sqlQuery);
      prepStmt.setObject(1, loginHistory.getId());
      prepStmt.setObject(2, loginHistory.getTransactionId());
      prepStmt.setObject(3, loginHistory.getUserId());
      prepStmt.setObject(4, loginHistory.getIpAddress());
      prepStmt.setObject(5, loginHistory.getHost());

      int rowInserted = prepStmt.executeUpdate();
      logger.debug("rowInserted: " + rowInserted);
      if (rowInserted == 1) return true;
      else return false;
    } finally {
      DaoUtility.releaseResources(prepStmt, rs, conn);
    }
  }
Exemplo n.º 2
0
  public int count() throws SQLException {

    Connection conn = null;
    String sqlQuery = "";
    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    int count = 0;
    try {
      conn = wcareConnector.getConnectionFromPool();
      sqlQuery = "select Count(*) as Count from TBL_LOGIN_HISTORY";

      prepStmt = conn.prepareStatement(sqlQuery);
      rs = prepStmt.executeQuery();
      while (rs.next()) {
        count = rs.getInt("Count");
      }
    } finally {
      DaoUtility.releaseResources(prepStmt, rs, conn);
    }
    return count;
  }