Example usage for java.sql ResultSet getDate

List of usage examples for java.sql ResultSet getDate

Introduction

In this page you can find the example usage for java.sql ResultSet getDate.

Prototype

java.sql.Date getDate(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

Usage

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.QcliveAbstractBaseIntegrationTest.java

/**
 * Retrieves a map with archive_info table values 
 *//* w ww. ja  va  2 s  .  c  o  m*/
protected List<Map<String, Object>> retrieveArchiveInfoRecords() {
    logger.info(" retrieveArchiveInfoRecords - IN");
    final List<Map<String, Object>> archiveInfoRecordsList = new ArrayList<Map<String, Object>>();
    localCommonTemplate.query(getArchiveInfoRecords, new RowCallbackHandler() {
        public void processRow(final ResultSet resultSet) throws SQLException {
            final Map<String, Object> elementIdMap = new HashMap<String, Object>();
            elementIdMap.put("ARCHIVE_ID", resultSet.getLong("ARCHIVE_ID"));
            elementIdMap.put("ARCHIVE_NAME", resultSet.getString("ARCHIVE_NAME"));
            elementIdMap.put("ARCHIVE_TYPE_ID", resultSet.getLong("ARCHIVE_TYPE_ID"));
            elementIdMap.put("CENTER_ID", resultSet.getLong("CENTER_ID"));
            elementIdMap.put("DISEASE_ID", resultSet.getLong("DISEASE_ID"));
            elementIdMap.put("PLATFORM_ID", resultSet.getLong("PLATFORM_ID"));
            elementIdMap.put("SERIAL_INDEX", resultSet.getLong("SERIAL_INDEX"));
            elementIdMap.put("REVISION", resultSet.getLong("REVISION"));
            elementIdMap.put("SERIES", resultSet.getLong("SERIES"));
            elementIdMap.put("DATE_ADDED", resultSet.getTimestamp("DATE_ADDED"));
            elementIdMap.put("DEPLOY_STATUS", resultSet.getString("DEPLOY_STATUS"));
            elementIdMap.put("DEPLOY_LOCATION", resultSet.getString("DEPLOY_LOCATION"));
            elementIdMap.put("IS_LATEST", resultSet.getLong("IS_LATEST"));
            elementIdMap.put("IS_LATEST", resultSet.getLong("INITIAL_SIZE_KB"));
            elementIdMap.put("FINAL_SIZE_KB", resultSet.getLong("FINAL_SIZE_KB"));
            elementIdMap.put("IS_LATEST_LOADED", resultSet.getLong("IS_LATEST_LOADED"));
            elementIdMap.put("DATA_LOADED_DATE", resultSet.getDate("DATA_LOADED_DATE"));
            archiveInfoRecordsList.add(elementIdMap);
        }
    });
    logger.info(" retrieveArchiveInfoRecords - OUT");
    return archiveInfoRecordsList;
}

From source file:mom.trd.opentheso.bdd.helper.GroupHelper.java

/**
 * Cette fonction permet de rcuprer l'historique des traductions d'un
 * groupe/* w w w  .ja  v  a2  s.  c om*/
 *
 * @param ds
 * @param idGroup
 * @param idThesaurus
 * @param lang
 * @return
 */
public ArrayList<NodeGroup> getGroupTraductionsHistoriqueAll(HikariDataSource ds, String idGroup,
        String idThesaurus, String lang) {

    Connection conn;
    Statement stmt;
    ArrayList<NodeGroup> nodeGroupList = null;

    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {

                String query = "select lexicalvalue, modified, idgroup, username from concept_group_label_historique, users "
                        + "where id = '" + idGroup + "'" + " and lang = '" + lang + "'" + " and idthesaurus = '"
                        + idThesaurus + "'" + " and concept_group_label_historique.id_user=users.id_user"
                        + "' order by modified DESC";

                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroup nodeGroup = new NodeGroup();
                        nodeGroup.getConceptGroup().setIdgroup(idGroup);
                        nodeGroup.setIdUser(resultSet.getString("username"));
                        nodeGroup.setModified(resultSet.getDate("modified"));
                        nodeGroup.getConceptGroup().setId(resultSet.getInt("idgroup"));
                        nodeGroup.getConceptGroup().setIdthesaurus(idThesaurus);
                        nodeGroup.setLexicalValue(resultSet.getString("lexicalvalue"));
                        nodeGroup.setIdLang(lang);
                        nodeGroupList.add(nodeGroup);
                    }
                }

            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All traductions historique of group : " + idGroup, sqle);
    }
    return nodeGroupList;
}

From source file:mom.trd.opentheso.bdd.helper.GroupHelper.java

/**
 * Cette fonction permet de rcuprer l'historique des traductions d'un
 * groupe  une date prcise/*from  www. ja v  a  2  s  .co  m*/
 *
 * @param ds
 * @param idGroup
 * @param idThesaurus
 * @param lang
 * @return
 */
public ArrayList<NodeGroup> getGroupTraductionsHistoriqueFromDate(HikariDataSource ds, String idGroup,
        String idThesaurus, String lang, Date date) {

    Connection conn;
    Statement stmt;
    ArrayList<NodeGroup> nodeGroupList = null;

    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {

                String query = "select lexicalvalue, modified, idgroup, username from concept_group_label_historique, users "
                        + "where id = '" + idGroup + "'" + " and lang = '" + lang + "'" + " and idthesaurus = '"
                        + idThesaurus + "'" + " and concept_group_label_historique.id_user=users.id_user"
                        + " and modified <= '" + date.toString() + "' order by modified DESC";

                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroup nodeGroup = new NodeGroup();
                        nodeGroup.getConceptGroup().setIdgroup(idGroup);
                        nodeGroup.setIdUser(resultSet.getString("username"));
                        nodeGroup.setModified(resultSet.getDate("modified"));
                        nodeGroup.getConceptGroup().setId(resultSet.getInt("idgroup"));
                        nodeGroup.getConceptGroup().setIdthesaurus(idThesaurus);
                        nodeGroup.setLexicalValue(resultSet.getString("lexicalvalue"));
                        nodeGroup.setIdLang(lang);
                        nodeGroupList.add(nodeGroup);
                    }
                }

            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting date traductions historique of group : " + idGroup, sqle);
    }
    return nodeGroupList;
}

From source file:in.sc.dao.ProductHelper.java

public List<ProductBean> getProductDetails(HashMap inputMap) {
    StringBuilder sql = new StringBuilder();
    ArrayList inputList = new ArrayList();
    sql.append(/*from  www  .jav a  2s  .  co m*/
            "Select distinct pl.productName AS productName,REPLACE(pm.unique_id,'-',' ') p_name ,pm.product_id,pm.product_id_sp,pm.product_id_pr,pm.product_id_91, ");
    sql.append(
            " b.b_name,newPrice,oldPrice,url,pl.imgLink,seller,pm.unique_id,li.p_url_exp,li.brand_url_exp,li.home_url_exp,li.category_url_exp, ");
    sql.append(
            " rs.RetailerName,rs.RetailerAddress,rs.RetailerDesc,rs.Logo, li.p_keywords,p_title,pm.p_desc,b_keywords,b_title,li.b_desc,h_keywords,h_title,h_desc, ");
    sql.append(
            " pl.country_id,pl.category_id,pl.pricedate, c.cat_name,c.s_cat_name,pm.short_desc,li.cat_name as urlcatname ");
    sql.append(
            " from product_transaction pl,brand_details b,product_details pm,linkgenerator li,category_details c,retailers rs ");
    sql.append(" where pl.unique_id=pm.unique_id ");
    sql.append(" and pl.brand_id=b.brand_id ");
    sql.append(" and pm.cat_id=c.cat_id ");
    sql.append(" and rs.Retailer_Id=pl.retailer_id ");
    sql.append(" AND li.category_id=pm.cat_id ");
    sql.append(" AND li.country_id=pl.country_id ");

    if (inputMap.containsKey(category)) {
        sql.append(" AND pl.category_id in(:" + category + ") ");
        inputList.add(inputMap.get(category));
    }
    if (inputMap.containsKey(country)) {
        sql.append(" AND pl.country_id in(:" + country + ") ");
        inputList.add(inputMap.get(country));
    }
    if (inputMap.containsKey(unique_id)) {
        sql.append(" AND pm.unique_id in(:" + unique_id + ") ");
        inputList.add(inputMap.get(unique_id));
    }

    sql.append(" order by pricedate desc,newPrice asc ");
    //        System.out.println("sql  " + sql.toString());
    namedParameterJdbcTemplate = getTemplate();
    List<ProductBean> detailList = namedParameterJdbcTemplate.query(sql.toString(), inputMap,
            new RowMapper<ProductBean>() {

                @Override
                public ProductBean mapRow(ResultSet rs, int rowNum) throws SQLException {
                    ProductBean pBean = new ProductBean();
                    MetaBean mbean = new MetaBean();
                    pBean.setNewPrice(rs.getInt("newPrice"));
                    pBean.setProductName(rs.getString("productName"));
                    pBean.setUniqueId(rs.getString("unique_id"));
                    pBean.setImgLink(getImgUrl(rs.getString("imgLink")));
                    pBean.setRetailer(rs.getString("RetailerName"));
                    pBean.setSeller(rs.getString("seller"));
                    pBean.setRetailerLogo(rs.getString("Logo"));
                    pBean.setSellerUrl(rs.getString("url"));
                    pBean.setUniqueName(rs.getString("p_name"));
                    pBean.setBrandName(rs.getString("b_Name"));
                    pBean.setCategoryid(rs.getInt("category_id"));
                    pBean.setCountryid(rs.getInt("country_id"));
                    pBean.setPriceDate(rs.getDate("pricedate"));
                    pBean.setPdesc(rs.getString("p_desc"));
                    if (pBean.getPdesc() == null) {
                        pBean.setPdesc(rs.getString("short_desc"));
                    }
                    pBean.setCategoryName(rs.getString("cat_name"));
                    pBean.setsCatName(rs.getString("s_cat_name"));
                    pBean.setProductId(rs.getInt("product_id"));

                    pBean.setUrl(generateUrl(rs.getString("p_url_exp"), rs.getString("unique_id"),
                            rs.getString("b_Name"), null));
                    pBean.setbUrl(generateUrl(rs.getString("brand_url_exp"), rs.getString("unique_id"),
                            rs.getString("b_Name"), null));
                    pBean.setCatUrl(generateUrl(rs.getString("category_url_exp"), rs.getString("unique_id"),
                            rs.getString("b_Name"), null));
                    pBean.setHomeurl(generateUrl(rs.getString("home_url_exp"), rs.getString("unique_id"),
                            rs.getString("b_Name"), null));

                    mbean.setP_title(ApplicationUtils.toTitleCase(generateUrl(rs.getString("p_title"),
                            rs.getString("unique_id"), rs.getString("b_Name"), "").replace("-", " ")));
                    mbean.setB_title(ApplicationUtils.toTitleCase(generateUrl(rs.getString("b_title"),
                            rs.getString("unique_id"), rs.getString("b_Name"), null).replace("-", " ")));
                    mbean.setH_title(ApplicationUtils.toTitleCase(generateUrl(rs.getString("h_title"),
                            rs.getString("unique_id"), rs.getString("b_Name"), null).replace("-", " ")));

                    mbean.setP_desc(ApplicationUtils.toTitleCase(generateUrl(rs.getString("p_desc"),
                            rs.getString("unique_id"), rs.getString("b_Name"), "").replace("-", " ")));
                    mbean.setB_desc(ApplicationUtils.toTitleCase(generateUrl(rs.getString("b_desc"),
                            rs.getString("unique_id"), rs.getString("b_Name"), null).replace("-", " ")));
                    mbean.setH_desc(ApplicationUtils.toTitleCase(generateUrl(rs.getString("h_desc"),
                            rs.getString("unique_id"), rs.getString("b_Name"), null).replace("-", " ")));

                    mbean.setP_keywords(ApplicationUtils.toTitleCase(generateUrl(rs.getString("p_keywords"),
                            rs.getString("unique_id"), rs.getString("b_Name"), "").replace("-", " ")));
                    mbean.setB_keywords(ApplicationUtils.toTitleCase(generateUrl(rs.getString("b_keywords"),
                            rs.getString("unique_id"), rs.getString("b_Name"), null).replace("-", " ")));
                    mbean.setH_keywords(ApplicationUtils.toTitleCase(generateUrl(rs.getString("h_keywords"),
                            rs.getString("unique_id"), rs.getString("b_Name"), null).replace("-", " ")));

                    pBean.setMbean(mbean);
                    pBean.setpListDesc(
                            (ArrayList) getProductListDesc(pBean.getProductId(), rs.getString("urlcatname")));
                    if (rs.getInt("product_id_pr") > 0) {
                        pBean.setFeatureId(rs.getInt("product_id_pr"));
                        pBean.setFeatureTable("product_feature_map_pr");
                        pBean.setFeatureSrcId(2);
                    } else if (rs.getInt("product_id_91") > 0) {
                        pBean.setFeatureId(rs.getInt("product_id_91"));
                        pBean.setFeatureTable("product_feature_map_91");
                        pBean.setFeatureSrcId(3);
                    } else if (rs.getInt("product_id_sp") > 0) {
                        pBean.setFeatureId(rs.getInt("product_id_sp"));
                        pBean.setFeatureTable("product_feature_map_sp");
                        pBean.setFeatureSrcId(1);
                    }
                    pBean.setgFeatureMap(generateFMap(pBean, "general"));
                    return pBean;
                }
            });
    return detailList;
}

From source file:org.apache.phoenix.end2end.DateTimeIT.java

@Test
public void testSelectLiteralDate() throws Exception {
    String s = DateUtil.DEFAULT_DATE_FORMATTER.format(date);
    String query = "SELECT DATE '" + s + "' FROM " + this.tableName;
    Statement statement = conn.createStatement();
    ResultSet rs = statement.executeQuery(query);
    assertTrue(rs.next());/*from  w ww  .j  a v a  2s  . c o m*/
    assertEquals(date, rs.getDate(1));
}

From source file:com.skilrock.lms.coreEngine.accMgmt.common.SearchChequeHelper.java

/**
 * This method is used to search cheque which are submitted by agent.
 * //from  www  . jav a  2  s  . com
 * @param searchMap
 * @return List of Cheques
 * @throws LMSException
 */
public List<ChequeBean> searchCheque(Map searchMap) throws LMSException {

    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;
    logger.debug("-----Query----::");
    try {

        ChequeBean chequeBean = null;
        List<ChequeBean> searchResults = new ArrayList<ChequeBean>();

        connection = DBConnect.getConnection();
        statement = connection.createStatement();

        String dynamicWhereClause = getWhereClause(searchMap);
        String orgCodeQry = " b.name orgCode ";

        if ((LMSFilterDispatcher.orgFieldType).equalsIgnoreCase("CODE")) {
            orgCodeQry = " b.org_code orgCode ";

        } else if ((LMSFilterDispatcher.orgFieldType).equalsIgnoreCase("CODE_NAME")) {
            orgCodeQry = " concat(b.org_code,'_',b.name)  orgCode";

        } else if ((LMSFilterDispatcher.orgFieldType).equalsIgnoreCase("NAME_CODE")) {
            orgCodeQry = " concat(b.name,'_',b.org_code)  orgCode ";

        }
        String query = "select a.transaction_id,a.cheque_nbr,a.cheque_date,a.issuing_party_name,a.drawee_bank,a.cheque_amt,"
                + orgCodeQry
                + ",b.organization_id  from st_lms_bo_sale_chq a, st_lms_organization_master b where a.agent_org_id=b.organization_id and a.transaction_type='CHEQUE' "
                + dynamicWhereClause;

        logger.debug("-----Query yogesh************----::" + query);

        resultSet = statement.executeQuery(query);

        while (resultSet.next()) {

            chequeBean = new ChequeBean();
            logger.debug("-----Query----::");

            chequeBean.setChequeNumber(resultSet.getString(TableConstants.CHEQUE_NUMBER));
            logger.debug("Cheque Date" + resultSet.getDate(TableConstants.CHEQUE_DATE));
            String sd = resultSet.getDate(TableConstants.CHEQUE_DATE).toString();
            Calendar cal = Calendar.getInstance();

            java.sql.Date sD = new java.sql.Date(cal.getTimeInMillis());

            chequeBean.setChequeDate(sd);
            chequeBean.setIssuePartyname(resultSet.getString(TableConstants.ISSUE_PARTY_NAME));
            chequeBean.setBankName(resultSet.getString(TableConstants.DRAWEE_BANK));
            chequeBean.setChequeAmount(resultSet.getDouble(TableConstants.CHEQUE_AMT));
            chequeBean.setOrgName(resultSet.getString("orgCode"));
            chequeBean.setOrgId(resultSet.getInt("organization_id"));
            chequeBean.setTransactionId(resultSet.getLong(TableConstants.TRANSACTION_ID));
            // chequeBean.setChequeBounceCharges(chequeBounceCharges);

            searchResults.add(chequeBean);

            logger.debug("Cheque Number" + resultSet.getString(TableConstants.CHEQUE_NUMBER));
            logger.debug("Org Name:" + resultSet.getString("orgCode"));
            logger.debug("Bank" + resultSet.getString(TableConstants.DRAWEE_BANK));

        }
        return searchResults;

    } catch (SQLException e) {
        logger.error("Exception: " + e);
        e.printStackTrace();
        throw new LMSException(e);
    } finally {

        try {
            if (resultSet != null) {
                resultSet.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException se) {
            logger.error("Exception: " + se);
            throw new LMSException(se);
        }
    }

}

From source file:nl.strohalm.cyclos.setup.migrations.version3_6.ClosedAccountBalancesMigration.java

@Override
public int execute(final JDBCWrapper jdbc) throws SQLException {

    // First, ensure the account status still exists, ie, not already migrated
    ResultSet accountStatusExists = null;
    try {//from  w  w  w.jav  a 2  s. co m
        accountStatusExists = jdbc.query("select 1 from account_status limit 1");
    } catch (final SQLException e) {
        // The already does not exists. Exit.
        return 0;
    } finally {
        JDBCWrapper.closeQuietly(accountStatusExists);
    }

    // Populate the account limit logs from both the account status and the pending account status tables
    jdbc.execute(
            "insert into account_limit_logs " + " (account_id, date, by_id, credit_limit, upper_credit_limit) "
                    + " select account_id, date, credit_limit_by_id, credit_limit, upper_credit_limit"
                    + " from account_status" + " where credit_limit_by_id is not null");

    jdbc.execute(
            "insert into account_limit_logs " + " (account_id, date, by_id, credit_limit, upper_credit_limit) "
                    + " select account_id, date, by_id, lower_limit, upper_limit"
                    + " from pending_account_status" + " where type = 'lim'");

    // Populate the amount_reservations table from pending transfers, scheduled payments which reserves the total amount and their installments
    jdbc.execute("insert into amount_reservations" + " (subclass, account_id, date, amount, transfer_id)"
            + " select 'P', from_account_id, date, amount, id " + " from transfers t " + " where t.status = ? ",
            Payment.Status.PENDING.getValue());
    jdbc.execute(
            "insert into amount_reservations" + " (subclass, account_id, date, amount, scheduled_payment_id)"
                    + " select 'S', from_account_id, date, amount, id " + " from scheduled_payments "
                    + " where reserve_amount = true ");
    jdbc.execute(
            "insert into amount_reservations" + " (subclass, account_id, date, amount, transfer_id)"
                    + " select 'I', t.from_account_id, ifnull(t.process_date, t.date), -t.amount, t.id "
                    + " from transfers t inner join scheduled_payments sp on t.scheduled_payment_id = sp.id"
                    + " where sp.reserve_amount = true and t.status <> ? ",
            Payment.Status.SCHEDULED.getValue());

    // Iterate each account
    int results = 0;
    final ResultSet accounts = jdbc.query("select id, creation_date from accounts");
    try {
        while (accounts.next()) {
            final long accountId = accounts.getLong("id");
            final Date creationDate = new Date(DateUtils
                    .truncate(accounts.getTimestamp("creation_date"), Calendar.DAY_OF_MONTH).getTime());
            // Get, by day, each diff, either for balance or reserved amount
            ResultSet diffs = jdbc.query(" select * from ( "
                    + "     select 'B' as type, b.date, b.balance as diff" + "     from ( "
                    + "         select date(date) as date, sum(amount) as balance " + "         from ( "
                    + "             select t.process_date as date, "
                    + "             case when t.chargeback_of_id is null then "
                    + "                 case when t.from_account_id = ? then -t.amount else t.amount end "
                    + "             else "
                    + "                 case when t.to_account_id = ? then t.amount else -t.amount end "
                    + "             end as amount " + "             from transfers t "
                    + "             where (t.from_account_id = ? or t.to_account_id = ?) "
                    + "               and t.process_date is not null " + "         ) t "
                    + "         group by date(date) " + "     ) b " + "     union "
                    + "     select 'R', date(r.date), sum(r.amount) " + "     from amount_reservations r "
                    + "     where r.account_id = ? " + "     group by date(r.date) " + " ) t "
                    + " where date < current_date() " + " order by date", accountId, accountId, accountId,
                    accountId, accountId);
            Date lastDate = creationDate;
            double balance = 0;
            double reserved = 0;
            try {
                boolean hasData = false;
                while (diffs.next()) {
                    hasData = true;
                    boolean isBalance = "B".equals(diffs.getString("type"));
                    Date date = diffs.getDate("date");
                    double diff = diffs.getDouble("diff");
                    if (!lastDate.equals(date)) {
                        // Insert a closed balance when the date changes
                        results += jdbc.execute(
                                "insert into closed_account_balances (date, account_id, balance, reserved) values (?, ?, ?, ?)",
                                nextDay(lastDate), accountId, balance, reserved);
                    }
                    if (isBalance) {
                        balance += diff;
                    } else {
                        reserved += diff;
                    }
                    lastDate = date;
                }
                if (hasData) {
                    // There is a last closed balance to insert
                    results += jdbc.execute(
                            "insert into closed_account_balances (date, account_id, balance, reserved) values (?, ?, ?, ?)",
                            nextDay(lastDate), accountId, balance, reserved);
                }
            } finally {
                JDBCWrapper.closeQuietly(diffs);
            }
            // Set the last closing date
            jdbc.execute("update accounts set last_closing_date = ? where id = ?", lastDate, accountId);
        }
    } finally {
        JDBCWrapper.closeQuietly(accounts);
    }

    // Now it is safe to drop the account_status table
    jdbc.execute("drop table account_status");
    jdbc.execute("drop table pending_account_status");

    return results;
}

From source file:com.skilrock.lms.web.scratchService.orderMgmt.common.ProcessRequestAction.java

@Override
public String execute() throws Exception {
    HttpSession session = getRequest().getSession();
    session.setAttribute("RequestList", null);
    session.setAttribute("orderId", null);
    session.setAttribute("TOTAL", null);
    session.setAttribute("BALANCE", null);
    session.setAttribute("CREDIT_LIMIT", null);
    session.setAttribute("CREDIT_AMT", null);

    list = new ArrayList<OrderRequestBean>();

    Connection conn = null;/*from  ww  w. j  a  v  a2 s.  c  om*/
    Statement statement = null;
    ResultSet resultSet = null;
    try {
        conn = DBConnect.getConnection();
        StringBuilder queryBuilder = new StringBuilder();
        String query = "SELECT a.order_id, a.order_date, b.name FROM st_se_bo_order a INNER JOIN st_lms_organization_master b ON a.agent_org_id=b.organization_id INNER JOIN st_se_bo_ordered_games c ON a.order_id=c.order_id INNER JOIN st_se_game_master d ON c.game_id=d.game_id WHERE a.order_status='REQUESTED'";
        query = CommonMethods.appendRoleAgentMappingQuery(query, "a.agent_org_id",
                ((UserInfoBean) session.getAttribute("USER_INFO")).getRoleId());// +" group by
        queryBuilder.append(query);
        if (gameName != null && gameName.length() > 0)
            queryBuilder.append(" AND game_name LIKE '%").append(gameName).append("%'");
        if (gameNumber != null && gameNumber.length() > 0)
            queryBuilder.append(" AND game_nbr LIKE '%").append(gameNumber).append("%'");
        if (agtOrgName != null && agtOrgName.length() > 0)
            queryBuilder.append(" AND name LIKE '%").append(agtOrgName).append("%'");
        if (orderNumber != null && orderNumber.length() > 0)
            queryBuilder.append(" AND order_status LIKE '%").append(orderNumber).append("%'");
        logger.info("Search - " + queryBuilder.toString());
        statement = conn.createStatement();
        resultSet = statement.executeQuery(queryBuilder.toString());
        while (resultSet.next()) {
            orderBean = new OrderRequestBean();
            orderId = resultSet.getInt("order_id");
            date = resultSet.getDate("order_date");
            name = resultSet.getString("name");
            orderBean.setOrderId(orderId);
            orderBean.setDate(date);
            orderBean.setName(name);
            list.add(orderBean);

        }
        session.setAttribute("RequestList", list);
        session.setAttribute("RequestList1", list);
        session.setAttribute("orderId", orderId);

        if (list != null && list.size() > 0) {
            session.setAttribute("startValueRequestSearch", new Integer(0));
            searchAjaxRequest();
        }
        setVarFromProcessRequest("Yes");
        return SUCCESS;
    } catch (SQLException se) {
        setVarFromProcessRequest("No");
        conn.rollback();
        System.out.println("We got an exception while preparing a statement:" + "Probably bad SQL.");
        throw new LMSException(se);

    } finally {

        try {
            if (resultSet != null) {
                resultSet.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException se) {
            throw new LMSException(se);
        }

    }

}

From source file:org.apache.phoenix.end2end.DateTimeIT.java

@Test
public void testCurrentDateWithNoTable() throws Exception {
    long expectedTime = System.currentTimeMillis();
    ResultSet rs = conn.createStatement().executeQuery("SELECT CURRENT_DATE()");
    assertTrue(rs.next());//  w  ww . j  av  a2 s .  c o  m
    long actualTime = rs.getDate(1).getTime();
    assertTrue(Math.abs(actualTime - expectedTime) < MILLIS_IN_DAY);
}

From source file:com.cnd.greencube.server.dao.jdbc.JdbcDAO.java

@SuppressWarnings("rawtypes")
private Object getColumnValue(ResultSet rs, ResultSetMetaData meta, int index, Class clazz) throws Exception {
    Object value = null;/*  www  . j av  a 2s .c  o m*/

    int type = meta.getColumnType(index);
    if (clazz == String.class) {
        value = rs.getString(index);
    } else if (clazz == Integer.class) {
        value = rs.getInt(index);
    } else if (clazz == Boolean.class) {
        value = rs.getBoolean(index);
    } else if (clazz == byte[].class) {
        if (type == Types.BLOB)
            value = rs.getBlob(index);
        else
            value = rs.getBytes(index);
    } else if (clazz == Long.class) {
        value = rs.getLong(index);
    } else if (clazz == BigInteger.class) {
        value = rs.getBigDecimal(index);
    } else if (clazz == Float.class) {
        value = rs.getFloat(index);
    } else if (clazz == Double.class) {
        value = rs.getDouble(index);
    } else if (clazz == java.util.Date.class) {
        Timestamp time = rs.getTimestamp(index);
        if (time == null)
            value = null;
        else {
            value = new java.util.Date(time.getTime());
        }
    } else if (clazz == java.sql.Date.class) {
        value = rs.getDate(index);
    } else if (clazz == java.sql.Time.class) {
        value = rs.getTime(index);
    } else if (clazz == java.sql.Timestamp.class) {
        value = rs.getTimestamp(index);
    } else {
        throw new Exception("Cannote determin this column type:" + meta.getColumnName(index));
    }
    return value;
}