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:Main.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

    response.setContentType("text/html");
    PrintWriter writer = response.getWriter();

    Connection connection = getConnection();
    if (connection != null) {
        String sql = "SELECT SYSDATE FROM DUAL";
        try {//from  w w  w.ja  v a  2s .c o m
            PreparedStatement statement = connection.prepareStatement(sql);
            ResultSet rs = statement.executeQuery();

            while (rs.next()) {
                Date date = rs.getDate("SYSDATE");
                writer.println("The current date is " + dateFormat.format(date));
            }
            connection.close();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

From source file:com.wabacus.system.datatype.DateType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Date dd = rs.getDate(iindex);
    if (dd == null)
        return null;
    return new Date(dd.getTime());
}

From source file:com.wabacus.system.datatype.DateType.java

public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Date dd = rs.getDate(column);
    if (dd == null)
        return null;
    return new Date(dd.getTime());
}

From source file:com.wabacus.system.datatype.CDateType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Date cdd = rs.getDate(iindex);
    if (cdd == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(cdd.getTime());/*w  ww.  j av  a  2 s  . c  om*/
    return cd;
}

From source file:com.wabacus.system.datatype.CDateType.java

public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException {
    java.sql.Date cdd = rs.getDate(column);
    if (cdd == null)
        return null;
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(cdd.getTime());//from w  ww  .j a va  2  s  . c  om
    return cd;
}

From source file:io.spring.batch.domain.CustomerRowMapper.java

@Override
public Customer mapRow(ResultSet resultSet, int i) throws SQLException {
    return new Customer(resultSet.getLong("id"), resultSet.getString("firstName"),
            resultSet.getString("lastName"), resultSet.getDate("birthdate"));
}

From source file:com.senior.g40.service.AccidentService.java

private void setAccident(ResultSet rs, Accident ac) throws SQLException {
    ac.setUserId(rs.getInt("userId"));
    ac.setDate(rs.getDate("date"));
    ac.setTime(rs.getString("time"));
    ac.setLatitude(rs.getFloat("latitude"));
    ac.setLongtitude(rs.getFloat("longtitude"));
    ac.setForceDetect(rs.getFloat("forceDetect"));
    ac.setSpeedDetect(rs.getFloat("speedDetect"));
    ac.setAccCode(rs.getString("accCode").charAt(0));
}

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

public JdbcPet mapRow(ResultSet rs, int rownum) throws SQLException {
    JdbcPet pet = new JdbcPet();
    pet.setId(rs.getInt("id"));
    pet.setName(rs.getString("name"));
    Date birthDate = rs.getDate("birth_date");
    pet.setBirthDate(new DateTime(birthDate));
    pet.setTypeId(rs.getInt("type_id"));
    pet.setOwnerId(rs.getInt("owner_id"));
    return pet;// w ww  .j a va  2 s  . c  om
}

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

@Override
public JdbcPet mapRow(ResultSet rs, int rownum) throws SQLException {
    JdbcPet pet = new JdbcPet();
    pet.setId(rs.getInt("id"));
    pet.setName(rs.getString("name"));
    Date birthDate = rs.getDate("birth_date");
    pet.setBirthDate(new DateTime(birthDate));
    pet.setTypeId(rs.getInt("type_id"));
    pet.setOwnerId(rs.getInt("owner_id"));
    return pet;// ww  w. j  av a  2  s  .  c  o m
}

From source file:org.smigo.message.JdbcMessageDao.java

@Override
public List<Message> getMessage(Locale locale, int from, int size) {
    final String whereParameter = locale.getLanguage() + "%";
    return jdbcTemplate.query(SELECT, new Object[] { whereParameter, from, size }, new RowMapper<Message>() {
        @Override//w  w w.jav a  2 s.c o m
        public Message mapRow(ResultSet rs, int rowNum) throws SQLException {
            return new Message(rs.getInt("id"), rs.getString("text"), rs.getString("username"),
                    rs.getDate("createdate"));
        }
    });
}