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:edu.clemson.cs.nestbed.server.adaptation.sql.ProgramProfilingSymbolSqlAdapter.java

private final ProgramProfilingSymbol getProfilingSymbol(ResultSet resultSet) throws SQLException {

    int id = resultSet.getInt(Index.ID.index());
    int tbDepConfID = resultSet.getInt(Index.PDCONFID.index());
    int programSymbolID = resultSet.getInt(Index.PROGSYMID.index());
    Date timestamp = resultSet.getDate(Index.TIMESTAMP.index());

    return new ProgramProfilingSymbol(id, tbDepConfID, programSymbolID, timestamp);
}

From source file:eu.databata.engine.dao.PropagationDAO.java

public PropagationLock getLockInfo() {
    return getJdbcTemplate().queryForObject("SELECT * FROM " + lockTable, new RowMapper<PropagationLock>() {

        @Override/*  w  ww.  ja v  a2 s .com*/
        public PropagationLock mapRow(ResultSet rs, int rowNum) throws SQLException {
            PropagationLock lock = new PropagationLock();
            lock.setToken(rs.getString("token"));
            lock.setLockTime(rs.getDate("lock_time"));

            return lock;
        }
    });
}

From source file:com.karki.spring.dao.impl.CourseDaoImpl.java

private Course mapData(ResultSet rs) throws SQLException {
    Course course = new Course();
    course.setId(rs.getInt("id"));
    course.setCourseName(rs.getString("course_name"));
    course.setCourseDescription(rs.getString("course_description"));
    course.setDurationType(rs.getString("duration_type"));
    course.setFees(rs.getDouble("fees"));
    course.setDuration(rs.getInt("duration"));
    course.setAddedDate(rs.getDate("added_date"));
    course.setModifiedDate(rs.getDate("modified_date"));
    course.setStatus(rs.getBoolean("status"));
    return course;
}

From source file:edu.pitt.resumecore.PatientVisit.java

public void setAllUserProperties(String sql) {
    this.examID = "";
    this.complaints = "";
    this.notes = "";

    try {//from   w w w  . j  a  v a  2  s.c om
        ResultSet rs = db.getResultSet(sql);
        if (rs.next()) {
            this.examID = rs.getString("examId");
            this.complaints = rs.getString("complaints");
            this.notes = rs.getString("notes");
            this.dateOfVisit = rs.getDate("dateOfVisit");

            Diagnosis diagnosis = new Diagnosis(rs.getString("diagnosisId"));
            this.diagnosisList.add(diagnosis);

            Symptom symptom = new Symptom(rs.getString("symptomId"));
            this.symptomList.add(symptom);

            User patient = new User(rs.getString("patientId"));

            Prescription prescription = new Prescription(this, patient);
            this.prescriptionList.add(prescription);
        }

    } catch (SQLException ex) {

        ErrorLogger.log(
                "An error had occured in PatientVisit(String examID) constructor of the PatientVisit class. "
                        + ex.getMessage());
        ErrorLogger.log(sql);
    }
}

From source file:com.mohit.program.DAO.impl.ProductDAOImpl.java

@Override
public Product getById(int id) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_product WHERE product_id=?";
    return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Product>() {

        @Override//w  ww .j  a  v a  2s. c  o m
        public Product mapRow(ResultSet rs, int i) throws SQLException {
            Product p = new Product();
            p.setId(rs.getInt("product_id"));
            p.setProductName(rs.getString("product_name"));
            p.setCostPrice(rs.getString("cost_price"));
            p.setSellingPrice(rs.getString("selling_price"));
            p.setQuantityAvailable(rs.getInt("quantity_available"));
            p.setAddedDate(rs.getDate("added_date"));
            p.setModifiedDate(rs.getDate("modified_date"));
            p.setStatus(rs.getBoolean("status"));
            return p;
        }
    });
}

From source file:com.fpmislata.banco.persistencia.impl.MovimientoBancarioDAOImplJDBC.java

@Override
public MovimientoBancario get(int id) {
    MovimientoBancario movimientoBancario = new MovimientoBancario();
    Connection connection = connectionFactory.getConnection();
    String SQL = "SELECT * FROM movimientobancario WHERE id = ? ";
    try {//from   ww  w . ja  v  a 2s.  c o m
        PreparedStatement preparedStatement = connection.prepareStatement(SQL);
        preparedStatement.setInt(1, id);
        ResultSet resultSet = preparedStatement.executeQuery();
        resultSet.next();
        movimientoBancario.setId(resultSet.getInt("id"));
        movimientoBancario.setCuentaPertenece(resultSet.getInt("cuentapertenece"));
        movimientoBancario.setImporte(resultSet.getString("importe"));
        movimientoBancario.setFecha(resultSet.getDate("fecha"));
        movimientoBancario.setSaldoTotal(resultSet.getString("saldototal"));
        movimientoBancario.setTipoMovimiento(resultSet.getString("tipomovimiento"));
        movimientoBancario.setConcepto(resultSet.getString("concepto"));

        return movimientoBancario;
    } catch (Exception ex) {
        throw new RuntimeException("Error al hacer la consulta", ex);
    } finally {
        try {
            connection.close();
        } catch (SQLException ex) {
            throw new RuntimeException(ex);
        }
    }

}

From source file:com.mohit.program.DAO.impl.ProductDAOImpl.java

@Override
public List<Product> getAll(boolean availability) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_product WHERE 1=1 ";

    if (availability) {
        sql += " AND status=1 ";
    }/*from  ww  w.  j  a v a 2 s.  c o  m*/

    return jdbcTemplate.query(sql, new RowMapper<Product>() {

        @Override
        public Product mapRow(ResultSet rs, int i) throws SQLException {
            Product p = new Product();
            p.setId(rs.getInt("product_id"));
            p.setProductName(rs.getString("product_name"));
            p.setCostPrice(rs.getString("cost_price"));
            p.setSellingPrice(rs.getString("selling_price"));
            p.setQuantityAvailable(rs.getInt("quantity_available"));
            p.setAddedDate(rs.getDate("added_date"));
            p.setModifiedDate(rs.getDate("modified_date"));
            p.setStatus(rs.getBoolean("status"));
            return p;
        }
    });
}

From source file:com.havoc.hotel.admin.dao.impl.UserDAOImpl.java

private User mapData(ResultSet rs) throws SQLException {
    User u = new User();
    u.setUserId(rs.getInt("user_id"));
    u.setFirstName(rs.getString("first_name"));
    u.setLastName(rs.getString("last_name"));
    u.setEmail(rs.getString("email"));
    u.setUsername(rs.getString("username"));
    u.setPassword(rs.getString("password"));
    u.setRoleId(rs.getInt("role_id"));
    u.setAddedDate(rs.getDate("added_date"));
    u.setStatus(rs.getBoolean("status"));
    return u;//from   www  . j  ava  2 s  .  co m
}

From source file:edu.clemson.cs.nestbed.server.adaptation.sql.ProjectSqlAdapter.java

private final Project getProject(ResultSet resultSet) throws SQLException {
    int id = resultSet.getInt(Index.ID.index());
    int testbedID = resultSet.getInt(Index.TESTBEDID.index());
    String name = resultSet.getString(Index.NAME.index());
    String description = resultSet.getString(Index.DESCRIPTION.index());
    Date timestamp = resultSet.getDate(Index.TIMESTAMP.index());

    return new Project(id, testbedID, name, description, timestamp);
}

From source file:mvc.dao.TarefaDAO.java

public Tarefa buscarTarefaPorId(Long id) {
    String sql = "select * from tarefas where id = ? ";
    try (PreparedStatement stmt = connection.prepareStatement(sql)) {
        stmt.setLong(1, id);/*from  w ww  .j a  v  a  2 s. co m*/
        ResultSet rs = stmt.executeQuery();
        Tarefa tarefa = new Tarefa();
        if (rs.next()) {
            tarefa.setId(rs.getLong("id"));
            tarefa.setDescricao(rs.getString("descricao"));
            tarefa.setFinalizado(rs.getBoolean("finalizado"));
            //montando data
            Calendar data = Calendar.getInstance();
            if (rs.getDate("dataFinalizacao") != null) {
                data.setTime(rs.getDate("dataFinalizacao"));
                System.out.println("data");
                tarefa.setDataFinalizacao(data);
            }
        }
        return tarefa;
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}