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:com.springapp.mvc.mappers.PriceRowMapper.java

@Override
public PriceRow mapRow(ResultSet resultSet, int i) throws SQLException {
    PriceRow priceRow = new PriceRow();

    priceRow.setCode(resultSet.getInt("code"));
    priceRow.setAmount(resultSet.getDouble("amount"));
    priceRow.setStartDate(resultSet.getDate("startdate"));
    priceRow.setEndDate(resultSet.getDate("enddate"));
    priceRow.setCurrency(Currency.getInstance(resultSet.getString("currency")));

    return priceRow;

}

From source file:com.autentia.tnt.bill.migration.support.MigratedInformationRecoverer.java

/**
 * Recupera la fecha de pago o cobro de cada una de las facturas cuyo tipo se envia por parametro
 * @param billType tipo de factura//from  w  w  w  .  j ava2s.c o  m
 */
public static Date[] getFechaFacturaMigrated(String billType) throws Exception {
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    LineNumberReader file = null;
    Date[] result = new Date[0];

    try {
        log.info("RECOVERING FECHAS " + billType + " MIGRADAS");

        // connect to database
        Class.forName(BillToBillPaymentMigration.DATABASE_DRIVER);
        con = DriverManager.getConnection(BillToBillPaymentMigration.DATABASE_CONNECTION,
                BillToBillPaymentMigration.DATABASE_USER, BillToBillPaymentMigration.DATABASE_PASS); //NOSONAR
        con.setAutoCommit(false); // DATABASE_PASS vacio.

        String sql = "SELECT bp.expirationDate FROM BillPayment bp, Bill b where bp.billId = b.id and b.billType = ? order by bp.expirationDate";
        pstmt = con.prepareStatement(sql);
        pstmt.setString(1, billType);

        rs = pstmt.executeQuery();

        rs.last();
        result = new Date[rs.getRow()];
        rs.beforeFirst();
        int counter = 0;

        while (rs.next()) {
            result[counter] = rs.getDate(1);
            log.info("\t" + result[counter]);
            counter++;
        }

    } catch (Exception e) {
        log.error("FAILED: WILL BE ROLLED BACK: ", e);
        if (con != null) {
            con.rollback();
        }

    } finally {
        cierraFichero(file);
        liberaConexion(con, pstmt, rs);
    }
    return result;
}

From source file:no.magott.training.ex2.ExchangeRateRowMapper.java

@Override
public ExchangeRate mapRow(ResultSet rs, int rowNum) throws SQLException {
    ExchangeRate exchangeRate = new ExchangeRate();
    exchangeRate.setId(rs.getInt("ID"));
    exchangeRate.setExchangeRate(rs.getDouble("EXCHANGE_RATE"));
    exchangeRate.setDate(rs.getDate("EXCHANGE_DATE"));
    exchangeRate.setFrom(rs.getString("FROM_CURRENCY"));
    exchangeRate.setTo(rs.getString("TO_CURRENCY"));
    return exchangeRate;
}

From source file:com.ewcms.component.query.dao.QueryDAO.java

private Article articleRowMapper(ResultSet rs) throws SQLException {
    Article vo = new Article();
    vo.setTitle(rs.getString("title"));
    vo.setAuthor(rs.getString("author"));
    if (rs.getDate("published") != null) {
        vo.setPublished(DATE_FORMAT.format(rs.getDate("published")));
    }/*from w ww. java  2  s .co  m*/
    vo.setChannelName(rs.getString("name"));
    vo.setUrl(rs.getString("url"));
    return vo;
}

From source file:net.freechoice.model.orm.Map_Profile.java

@Override
public FC_Profile mapRow(final ResultSet rs, int arg1) throws SQLException {

    FC_Profile prof = new FC_Profile();
    prof.id = rs.getInt(1);//w w w. j a  v a  2  s. c  o m
    prof.id_user_ = rs.getInt(2);
    prof.date_register = rs.getDate(3);
    prof.site_personal = rs.getString(4);
    prof.name_first = rs.getString(5);
    prof.name_last = rs.getString(6);
    prof.contact_public = rs.getString(7);
    prof.gender = rs.getBoolean(8);
    prof.date_birth = rs.getDate(9);
    return prof;
}

From source file:com.pet.demo.repository.jdbc.JdbcVisitRepositoryImpl.java

public List<Visit> findByPetId(Integer petId) {
    final List<Visit> visits = this.jdbcTemplate.query(
            "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
            new ParameterizedRowMapper<Visit>() {
                public Visit mapRow(ResultSet rs, int row) throws SQLException {
                    Visit visit = new Visit();
                    visit.setId(rs.getInt("id"));
                    Date visitDate = rs.getDate("visit_date");
                    visit.setDate(new DateTime(visitDate));
                    visit.setDescription(rs.getString("description"));
                    return visit;
                }/*from w  w w  .j  ava2  s  .c o m*/
            }, petId);
    return visits;
}

From source file:com.xinferin.dao.DAOActivationImpl.java

@Override
public List<Activation> list() {
    String sql = "SELECT * FROM activation";
    List<Activation> list = jdbcTemplate.query(sql, new RowMapper<Activation>() {
        @Override//w  ww.  j  a v a  2 s  .c  om
        public Activation mapRow(ResultSet rs, int rowNum) throws SQLException {
            Activation aActivation = new Activation();

            aActivation.setLicence_id(rs.getInt("licence_id"));
            aActivation.setDate(rs.getDate("date"));
            aActivation.setMachine_code(rs.getString("machine_code"));
            aActivation.setIpaddress(rs.getString("ipaddress"));
            aActivation.setSuccess(rs.getInt("success"));

            return aActivation;
        }
    });
    return list;
}

From source file:com.branded.holdings.qpc.repository.jdbc.JdbcVisitRepositoryImpl.java

@Override
public List<Visit> findByPetId(Integer petId) {
    final List<Visit> visits = this.jdbcTemplate.query(
            "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
            new BeanPropertyRowMapper<Visit>() {
                @Override//w ww.  java 2s .c o  m
                public Visit mapRow(ResultSet rs, int row) throws SQLException {
                    Visit visit = new Visit();
                    visit.setId(rs.getInt("id"));
                    Date visitDate = rs.getDate("visit_date");
                    visit.setDate(new DateTime(visitDate));
                    visit.setDescription(rs.getString("description"));
                    return visit;
                }
            }, petId);
    return visits;
}

From source file:com.logAnything.tvShows.TVShowRowMapper.java

@Override
public TVShow mapRow(ResultSet rs, int i) throws SQLException {
    TVShow tvShow = new TVShow();
    tvShow.setId(rs.getInt("id"));
    tvShow.setTitle(rs.getString("title"));
    tvShow.setDayOfWeek(rs.getString("dayOfWeek"));
    tvShow.setDownloadDate(formatDate(rs.getDate("downloadDate")));
    tvShow.setLatestEpisode(rs.getInt("latestEpisode"));
    return tvShow;
}

From source file:com.rambird.miles.repository.jdbc.JdbcVisitRepositoryImpl.java

@Override
public List<Visit> findByPetId(Integer petId) {
    final List<Visit> visits = this.jdbcTemplate.query(
            "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
            new ParameterizedRowMapper<Visit>() {
                @Override/*from   ww  w  .  j  a  va  2s  . co m*/
                public Visit mapRow(ResultSet rs, int row) throws SQLException {
                    Visit visit = new Visit();
                    visit.setId(rs.getInt("id"));
                    Date visitDate = rs.getDate("visit_date");
                    visit.setDate(new DateTime(visitDate));
                    visit.setDescription(rs.getString("description"));
                    return visit;
                }
            }, petId);
    return visits;
}