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.carfinance.module.customermanage.domain.CustomerInfoRowMapper.java

public CustomerInfo mapRow(ResultSet rs, int arg1) throws SQLException {
    CustomerInfo customerInfo = new CustomerInfo();

    customerInfo.setId(rs.getLong("id"));
    customerInfo.setCertificate_type(rs.getString("certificate_type"));
    customerInfo.setCertificate_no(rs.getString("certificate_no"));
    customerInfo.setCustomer_name(rs.getString("customer_name"));
    customerInfo.setCustomer_dn(rs.getString("customer_dn"));
    customerInfo.setCustomer_email(rs.getString("customer_email"));
    customerInfo.setCreate_at(rs.getDate("create_at"));
    customerInfo.setCreate_by(rs.getLong("create_by"));
    customerInfo.setUpdate_at(rs.getDate("update_at"));
    customerInfo.setUpdate_by(rs.getLong("update_at"));
    customerInfo.setCustomer_type(rs.getString("customer_type"));

    customerInfo.setCustomer_house(rs.getString("customer_house"));
    customerInfo.setCustomer_vehicle(rs.getString("customer_vehicle"));
    customerInfo.setCustomer_guarantee(rs.getString("customer_guarantee"));

    customerInfo.setVip_no(rs.getString("vip_no"));

    customerInfo.setCertificate_url(rs.getString("certificate_url"));
    customerInfo.setCertificate_name(rs.getString("certificate_name"));

    try {// w  w w . j ava 2  s  .c o m
        customerInfo.setIdentity_name(rs.getString("identity_name"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setIdentity_url(rs.getString("identity_url"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setHouse_property_name(rs.getString("house_property_name"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setHouse_property_url(rs.getString("house_property_url"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setDriving_license_name(rs.getString("driving_license_name"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setDriving_license_url(rs.getString("driving_license_url"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setOther_name(rs.getString("other_name"));
    } catch (Exception e) {
    }
    try {
        customerInfo.setOther_url(rs.getString("other_url"));
    } catch (Exception e) {
    }

    return customerInfo;
}

From source file:com.bs.beans.SalesBean.java

public void memoFindview() {
    Connection con = DB.getConnection();
    try {//from   ww  w .  ja  va  2 s  .co m
        PreparedStatement stm = con.prepareCall("select * from sales where MemoNo=?");
        stm.setInt(1, 4);
        ResultSet rs = stm.executeQuery();
        double gt = 0.0;
        while (rs.next()) {
            gt += rs.getDouble(6);
            setDate(rs.getString(7));
            slsList11.add(new SeslesReport(rs.getInt(8), rs.getInt(2), rs.getString(3), rs.getInt(5),
                    rs.getDouble(6), rs.getDate(7), rs.getInt(9)));
            System.out.println(rs.getDouble("Total"));
        }
        setGtota2(gt);
        con.close();
        rs.close();
    } catch (Exception e) {
        System.out.println(e.toString());
    }

}

From source file:br.com.fatecpg.repositories.mysql.MySqlLogRepository.java

@Override
public Log getById(int id) {
    if (id <= 0) {
        throw new IllegalArgumentException("id must be greather than 0.");
    }//from ww  w .j av  a 2 s  .c o m

    Log log = null;

    String sql = "select id, applicationName, message, url, ipaddress, usernamme, createdon, details from log where id = ?";
    Connection connection = dbProvider.getConnection();

    try {

        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1, id);

        ResultSet resultSet = preparedStatement.executeQuery();

        if (resultSet.next()) {
            log = new Log();
            log.setId(resultSet.getInt("id"));
            log.setApplicationName(resultSet.getString("applicationName"));
            log.setMessage(resultSet.getString("message"));
            log.setUrl(resultSet.getString("url"));
            log.setIpAddress("ipaddress");
            log.setUsername(resultSet.getString("username"));
            log.setCreatedDate(resultSet.getDate("createdOn"));
            log.setDetails(resultSet.getString("details"));
        }

    } catch (SQLException ex) {
        throw new RuntimeException(ex);
    }

    return log;
}

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

private final ProgramSymbol getProgramSymbol(ResultSet resultSet) throws SQLException {
    int id = resultSet.getInt(Index.ID.index());
    int programID = resultSet.getInt(Index.PROGID.index());
    String module = resultSet.getString(Index.MODULE.index());
    String symbol = resultSet.getString(Index.SYMBOL.index());
    int address = resultSet.getInt(Index.ADDRESS.index());
    short size = resultSet.getShort(Index.SIZE.index());
    Date timestamp = resultSet.getDate(Index.TIMESTAMP.index());

    return new ProgramSymbol(id, programID, module, symbol, address, size, timestamp);
}

From source file:com.blackducksoftware.tools.commonframework.standard.codecenter.dao.CodeCenter6_6_1DbDao.java

/**
 * Get remediation dates. Can use this to check to see whether the
 * componentuse_vulnerabilty record exists yet.
 *
 * @param vulnId/* ww w .jav  a 2  s.c o m*/
 * @param compUseId
 * @return
 * @throws SQLException
 */
private RemediationDates getRemediationDates(String vulnId, String compUseId) throws SQLException {
    log.debug("Fetching date_remediation, date_completion from componentuse_vulnerability table for vulnId: "
            + vulnId + " / compUseId: " + compUseId);
    RemediationDates dates = null;

    Statement stmt = connBdsCatalog.createStatement();
    String sql = "SELECT date_remediation,date_completion FROM componentuse_vulnerability "
            + "WHERE vulnerability_id = " + vulnId + " " + "AND componentuse_id = '" + compUseId + "'";

    try {
        ResultSet rs = stmt.executeQuery(sql);
        if (rs.next()) {
            Date targetRemediationDate = rs.getDate("date_remediation");
            Date actualRemediationDate = rs.getDate("date_completion");
            dates = new RemediationDates(targetRemediationDate, actualRemediationDate);
            log.debug("From DB: target remediation date: " + targetRemediationDate + " ("
                    + getTimeMillis(targetRemediationDate) + ")" + "; actual remediation date: "
                    + actualRemediationDate + " (" + getTimeMillis(actualRemediationDate) + ")");
        }
    } catch (SQLException e) {
        log.debug("Error executing SQL: " + sql);
        log.warn(
                "Unable to read componentuse_vulnerability remediation dates, which were added in Code Center 6.7.1p2; "
                        + " This is normal when running against older Code Center servers.");
    }
    return dates;
}

From source file:com.sfs.whichdoctor.dao.WorkshopDAOImpl.java

/**
 * Load workshop./*from   ww  w  .  j  a v  a 2s .c o m*/
 *
 * @param rs the rs
 * @param fullResults the full results
 * @return the workshop bean
 * @throws SQLException the SQL exception
 */
private WorkshopBean loadWorkshop(final ResultSet rs, final boolean fullResults) throws SQLException {

    WorkshopBean workshop = new WorkshopBean();

    workshop.setId(rs.getInt("WorkshopId"));
    workshop.setGUID(rs.getInt("GUID"));
    workshop.setReferenceGUID(rs.getInt("ReferenceGUID"));
    workshop.setType(rs.getString("Type"));
    try {
        workshop.setWorkshopDate(rs.getDate("Date"));
    } catch (SQLException e) {
        workshop.setWorkshopDate(null);
    }
    workshop.setMemo(rs.getString("Memo"));

    workshop.setActive(rs.getBoolean("Active"));

    try {
        workshop.setCreatedDate(rs.getTimestamp("CreatedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading CreatedDate: " + sqe.getMessage());
    }
    workshop.setCreatedBy(rs.getString("CreatedBy"));
    try {
        workshop.setModifiedDate(rs.getTimestamp("ModifiedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ModifiedDate: " + sqe.getMessage());
    }
    workshop.setModifiedBy(rs.getString("ModifiedBy"));

    return workshop;
}

From source file:API.Distributions.java

JSONArray getDistributions() {

    /* produce json */

    JSONArray json = new JSONArray();
    try {//from w  ww. ja  va  2  s. com
        String sql = "";
        PreparedStatement s = con.prepareStatement(sql);
        if (type == 0) {
            sql = ("SELECT * from distributions;");
            s = con.prepareStatement(sql);
        } else if (type == 1) {
            sql = ("SELECT * from distributions where type = 'request' and to_location_id = ?;");
            s = con.prepareStatement(sql);
            s.setInt(1, location_id);
        }

        ResultSet rs = s.executeQuery();
        JSONObject object;

        while (rs.next()) {
            object = new JSONObject();
            object.put("dist_id", rs.getInt(1));
            object.put("type", rs.getString(2));
            object.put("to_location_id", rs.getInt(3));
            object.put("from_location_id", rs.getInt(4));
            object.put("date_filled", rs.getDate(5));
            object.put("status", rs.getString(6));
            object.put("percent_completed", rs.getFloat(7));
            object.put("date_completed", rs.getDate(8));
            json.put(object);
        }

    } catch (JSONException | SQLException ex) {
        Logger.getLogger(Distributions.class.getName()).log(Level.SEVERE, null, ex);
    }
    return json;
}

From source file:org.extremesite.dao.PresidentsDao.java

public Collection getPresidents(String query) {
    query = "SELECT" + query;

    return jdbcTemplate.query(query, new ResultReader() {
        List results = new ArrayList();

        public List getResults() {
            return results;
        }/*w  ww  . jav  a  2s  .  c o m*/

        public void processRow(ResultSet rs) throws SQLException {
            President president = new President();
            president.setPresidentId(new Integer(rs.getInt("presidentId")));
            president.setFirstName(rs.getString("firstName"));
            president.setLastName(rs.getString("lastName"));
            president.setNickName(rs.getString("nickName"));
            president.setFullName(rs.getString("fullName"));
            president.setTerm(rs.getString("term"));
            president.setBorn(rs.getDate("born"));
            president.setDied(rs.getDate("died"));
            president.setEducation(rs.getString("education"));
            president.setCareer(rs.getString("career"));
            president.setPoliticalParty(rs.getString("politicalParty"));
            results.add(president);
        }
    });
}

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

private final Program getProgram(ResultSet resultSet) throws SQLException {
    int id = resultSet.getInt(Index.ID.index());
    int projectID = resultSet.getInt(Index.PROJECTID.index());
    String name = resultSet.getString(Index.NAME.index());
    String description = resultSet.getString(Index.DESCRIPTION.index());
    String sourcePath = resultSet.getString(Index.SOURCEPATH.index());
    Date timestamp = resultSet.getDate(Index.TIMESTAMP.index());

    return new Program(id, projectID, name, description, sourcePath, timestamp);
}

From source file:jp.co.tis.gsp.tools.dba.dialect.OracleDialect.java

/**
 * Oracle?DateTimestamp??getString()?????load-data??? <br />
 * ??????????/*from ww  w .j a v a2 s  . co  m*/
 */
@Override
public String convertLoadData(ResultSet resultSet, int columnIndex, String columnLabel, int sqlType)
        throws SQLException {
    String value = null;
    switch (sqlType) {
    case Types.DATE:
        Date date = resultSet.getDate(columnLabel);
        if (date != null) {
            value = sdfDate.format(date);
        }
        break;
    default:
        value = super.convertLoadData(resultSet, columnIndex, columnLabel, sqlType);
        break;
    }

    // null to blank.
    value = StringUtils.defaultIfEmpty(value, "");

    return value;
}