Example usage for java.sql ResultSet getLong

List of usage examples for java.sql ResultSet getLong

Introduction

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

Prototype

long getLong(String columnLabel) throws SQLException;

Source Link

Document

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

Usage

From source file:com.github.binarywang.demo.spring.dao.AppointmentDao.java

public Long countForDay(String date, int time) {
    return jdbcTemplate.queryForObject("select count(id) from appointment where date = ? and time = ?",
            new Object[] { date, time }, new RowMapper<Long>() {
                @Override/*from ww w. j  a  v a2  s  .  c o  m*/
                public Long mapRow(ResultSet resultSet, int i) throws SQLException {
                    return resultSet.getLong(1);
                }
            });
}

From source file:sample.contact.dao.impl.MenuDaoImpl.java

private Menu mapMenu(ResultSet rs) throws SQLException {
    Menu menu = new Menu();
    menu.setId(new Long(rs.getLong("id")));
    menu.setName(rs.getString("menu_name"));
    menu.setPath(rs.getString("menu_path"));

    return menu;//from   w ww . jav  a2s . c  o m
}

From source file:com.ewcms.content.particular.dao.FrontEnterpriseArticleDAO.java

private EnterpriseArticle interactionRowMapper(ResultSet rs) throws SQLException {
    EnterpriseArticle vo = new EnterpriseArticle();
    vo.setId(rs.getLong("id"));
    vo.setDense(Dense.valueOf(rs.getString("dense")));
    vo.setPublished(rs.getDate("published"));
    vo.setEnterpriseBasic(frontEnterpriseBasicDAO.get(rs.getLong("enterprisebasic_yyzzzch")));
    return vo;// ww w  .  j av  a 2  s  . c o m
}

From source file:io.kahu.hawaii.util.call.sql.response.UpdateIdResponseHandler.java

@Override
public void addToResponse(PreparedStatement payload, Response<Long> response) throws ServerException {
    try {//from ww  w .  j  av a 2s  .  com
        ResultSet keys = payload.getGeneratedKeys();
        if (keys != null) {
            try {
                keys.next();
                Long keyValue = keys.getLong(1);
                response.set(keyValue);
            } finally {
                JdbcUtils.closeResultSet(keys);
            }
        }
    } catch (SQLException e) {
        response.setStatus(ResponseStatus.BACKEND_FAILURE, e);
    }
}

From source file:mum.bigdata.car.recommender.repository.impl.MakeRepositoryImpl.java

@Override
public List<Make> buildResult(ResultSet rs) throws SQLException {
    List<Make> makes = new ArrayList<>();
    while (rs.next()) {
        Make make = new Make();
        make.setId(rs.getLong("make.id"));
        make.setName(rs.getString("make.name"));
        makes.add(make);/*from   w w w .j  av  a2 s . com*/
    }
    return makes;
}

From source file:com.budiana.irpan.belajar.dao.PesertaDaoTest.java

@Test
public void testInsert() throws SQLException {
    Peserta p = new Peserta();
    p.setNama("Peserta 01");
    p.setEmail("peserta01@gmail.com");
    p.setTanggalLahir(new Date());

    pd.save(p);//from ww  w. ja  va  2 s  .  c o  m
    String sql = "select count(*) as jumlah from peserta where email = 'peserta01@gmail.com'";
    try (Connection c = ds.getConnection()) {
        ResultSet rs = c.createStatement().executeQuery(sql);
        Assert.assertTrue(rs.next());

        Long jumlahRow = rs.getLong("jumlah");
        Assert.assertEquals(1L, jumlahRow.longValue());
        c.close();
    }
}

From source file:org.jasig.schedassist.impl.statistics.AppointmentEventRowMapper.java

/**
 * Expects the following columns in the {@link ResultSet}:
 * //from   w  ww .j  a  v  a  2  s . com
 <pre>
  event_id
  owner_id
  visitor_id,
  event_type,
  event_timestamp,
  event_start 
 </pre>
 * 
 * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
 */
@Override
public AppointmentEvent mapRow(ResultSet rs, int rowNum) throws SQLException {
    AppointmentEvent event = new AppointmentEvent();

    event.setEventId(rs.getLong("EVENT_ID"));
    final long ownerId = rs.getLong("OWNER_ID");
    event.setOwnerId(ownerId);
    IScheduleOwner owner = ownerDao.locateOwnerByAvailableId(ownerId);
    event.setScheduleOwner(owner);

    final String visitorId = rs.getString("VISITOR_ID");
    event.setVisitorId(visitorId);

    event.setEventType(EventType.valueOf(rs.getString("EVENT_TYPE")));
    event.setEventTimestamp(rs.getTimestamp("EVENT_TIMESTAMP"));
    event.setAppointmentStartTime(rs.getTimestamp("EVENT_START"));

    return event;
}

From source file:com.grayfox.server.dao.jdbc.CategoryJdbcDao.java

protected Category findByFoursquareId(String foursquareId, Locale locale) {
    return getJdbcTemplate().queryForObject(getQuery("Category.findByFoursquareId", locale),
            (ResultSet rs, int i) -> {
                Category category = new Category();
                int columnIndex = 1;
                category.setId(rs.getLong(columnIndex++));
                category.setName(rs.getString(columnIndex++));
                category.setIconUrl(rs.getString(columnIndex++));
                category.setFoursquareId(foursquareId);
                return category;
            }, foursquareId);//from   w  w  w. j  a  v a2  s  . co  m
}

From source file:com.grayfox.server.dao.jdbc.CategoryJdbcDao.java

protected List<Category> findByPoiFoursquareId(String foursquareId, Locale locale) {
    return getJdbcTemplate().query(getQuery("Category.findByPoiFoursquareId", locale),
            (ResultSet rs, int i) -> {
                Category category = new Category();
                int columnIndex = 1;
                category.setId(rs.getLong(columnIndex++));
                category.setName(rs.getString(columnIndex++));
                category.setIconUrl(rs.getString(columnIndex++));
                category.setFoursquareId(rs.getString(columnIndex++));
                return category;
            }, foursquareId);// w ww.ja  v  a  2 s . co m
}

From source file:io.kahu.hawaii.util.spring.AbstractDBRepository.java

protected Long getLong(final ResultSet rs, final int columnIndex) throws SQLException {
    long result = rs.getLong(columnIndex);
    return rs.wasNull() ? null : result;
}