List of usage examples for java.sql ResultSet getDate
java.sql.Date getDate(String columnLabel) throws SQLException;
ResultSet
object as a java.sql.Date
object in the Java programming language. From source file:org.pegadi.server.sources.SourceServerImpl.java
private Contact getContactFromResultSet(ResultSet rs) throws SQLException { Contact c = new Contact(); c.setID(rs.getInt(1));//from w w w . j av a 2 s . c om c.setSourceID(rs.getInt(2)); c.setDate(rs.getDate(3)); c.setNotes(rs.getString(4)); return c; }
From source file:com.trackplus.ddl.GenericStringValueConverter.java
@Override public String getStringValue(ResultSetMetaData rsmd, int idx, ResultSet rs, String tableName) throws SQLException, DDLException { String value = null;//from ww w.j a v a2 s. co m int type = rsmd.getColumnType(idx); String columnName = rsmd.getColumnName(idx); if (tableName.equalsIgnoreCase("TSITE") && columnName.equalsIgnoreCase("EXPDATE")) { Date d = rs.getDate(idx); if (d != null) { value = "'" + d + "'"; } } else { value = extractColumnValue(rs, idx, type); } return value; }
From source file:me.redstarstar.rdfx.duty.dao.jdbc.ScheduleJdbcDao.java
@Override public Schedule getScheduleByWeek(long parentId, int week) { return jdbcTemplate.execute((Statement statement) -> { ResultSet rs = statement.executeQuery("SELECT * FROM schedule WHERE parent_id = " + parentId + " AND week = " + week + " ORDER BY activity_date"); Schedule schedule = null;/*from w ww .jav a 2 s . c o m*/ if (rs.next()) { schedule = new Schedule(); schedule.setActivityDate(rs.getDate("activity_date").toLocalDate()); schedule.setParentId(rs.getLong("parent_id")); schedule.setWeek(rs.getInt("week")); } return schedule; }); }
From source file:br.com.asisprojetos.mapper.TBContratoMapper.java
@Override public TBContrato mapRow(ResultSet rs, int rowNum) throws SQLException { TBContrato tbContrato = new TBContrato(); tbContrato.setCodContrato(rs.getInt("COD_CONTRATO")); tbContrato.setCodCliente(rs.getInt("COD_CLIENTE")); tbContrato.setCodVendedor(rs.getInt("COD_VENDEDOR")); tbContrato.setNumContrato(rs.getString("NUM_CONTRATO")); tbContrato.setDataVigenciaIni(rs.getDate("DAT_VIGENCIA_INI")); tbContrato.setDataVigenciaFim(rs.getDate("DAT_VIGENCIA_FIM")); tbContrato.setComissao(rs.getFloat("COMISSAO")); tbContrato.setQtdProcessMes(rs.getInt("QTD_PROCESS_MES")); tbContrato.setQtdProcessAtu(rs.getInt("QTD_PROCESS_ATU")); tbContrato.setDataUltimaAtu(rs.getDate("DAT_ULTIMA_ATU")); tbContrato.setDataCriacao(rs.getDate("DAT_CRIACAO")); tbContrato.setQtdCnpj(rs.getInt("QTD_CNPJ")); tbContrato.setQtdNF(rs.getInt("QTD_NF")); tbContrato.setQtdParcelas(rs.getInt("QTD_PARCELAS")); tbContrato.setValor(rs.getFloat("VALOR")); tbContrato.setInAtivo(StringUtils.equals(rs.getString("IN_ATIVO"), "A")); tbContrato.setFerramenta(rs.getInt("FERRAMENTA")); tbContrato.setPrioridade(rs.getInt("PRIORIDADE")); return tbContrato; }
From source file:me.redstarstar.rdfx.duty.dao.jdbc.ScheduleJdbcDao.java
@Override public List<Schedule> listSchedulesByWeek(int week) { return jdbcTemplate.execute((Statement statement) -> { ResultSet rs = statement .executeQuery("SELECT * FROM schedule WHERE week = " + week + " ORDER BY activity_date"); List<Schedule> schedules = new ArrayList<>(); while (rs.next()) { Schedule schedule = new Schedule(); schedule.setActivityDate(rs.getDate("activity_date").toLocalDate()); schedule.setParentId(rs.getLong("parent_id")); schedule.setWeek(rs.getInt("week")); schedules.add(schedule);/*from w w w .j a v a2 s. c o m*/ } return schedules; }); }
From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet.java
/** * @param connection/*from ww w . j a v a 2 s . co m*/ * @param series * @param metrica * @param timeBegin * @param timeEnd * @param dataset * @throws SQLException */ private void getMetrics(Connection connection, String series, String metrica, long timeBegin, long timeEnd, DefaultCategoryDataset dataset) throws SQLException { PreparedStatement stmt = null; try { // String dateStr = format.format(calendar.getTime()); // System.out.println("!!! " + dateStr); SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy"); stmt = connection.prepareStatement("SELECT METRIC_VALUE_LONG, METRIC_DATE" + " FROM WEBDICOM.DAYSTAT WHERE METRIC_NAME = ? and " + " METRIC_DATE BETWEEN ? AND ? "); stmt.setString(1, metrica); stmt.setDate(2, new java.sql.Date(timeBegin)); stmt.setDate(3, new java.sql.Date(timeEnd)); ResultSet rs = stmt.executeQuery(); while (rs.next()) { long value = rs.getLong("METRIC_VALUE_LONG") / 1000; Date date = rs.getDate("METRIC_DATE"); String dateStr = format.format(date.getTime()); String category = dateStr; dataset.addValue(value, series, category); // System.out.println("!!!! ALL_DCM_SIZE="+dateStr+"="+value); } rs.close(); } finally { if (stmt != null) stmt.close(); } }
From source file:com.carfinance.module.vehiclemanage.domain.VehicleMaintailRowMapper.java
public VehicleMaintail mapRow(ResultSet rs, int arg1) throws SQLException { VehicleMaintail vehicleMaintail = new VehicleMaintail(); vehicleMaintail.setId(rs.getLong("id")); vehicleMaintail.setCarframe_no(rs.getString("carframe_no")); vehicleMaintail.setEngine_no(rs.getString("engine_no")); vehicleMaintail.setLicense_plate(rs.getString("license_plate")); vehicleMaintail.setMaintain_date(rs.getDate("maintain_date")); vehicleMaintail.setMaintain_content(rs.getString("maintain_content")); vehicleMaintail.setMaintain_price(rs.getDouble("maintain_price")); vehicleMaintail.setCurrent_km(rs.getLong("current_km")); vehicleMaintail.setNext_maintain_km(rs.getLong("next_maintain_km")); vehicleMaintail.setUser_id(rs.getLong("user_id")); vehicleMaintail.setUser_name(rs.getString("user_name")); vehicleMaintail.setCreate_by(rs.getLong("create_by")); vehicleMaintail.setCreate_at(rs.getDate("create_at")); vehicleMaintail.setUpdate_by(rs.getLong("update_by")); vehicleMaintail.setUpdate_at(rs.getDate("update_at")); return vehicleMaintail; }
From source file:com.nabla.dc.server.xml.settings.XmlCompany.java
public void load(final Connection conn, final Integer id) throws SQLException { asset_categories = new XmlCompanyAssetCategoryList(conn, id); accounts = new XmlAccountList(conn, id); users = new XmlCompanyUserList(conn, id); // find first financial year + period final PreparedStatement stmt = StatementFormat.prepare(conn, "SELECT f.name, p.end_date" + " FROM period_end AS p INNER JOIN financial_year AS f ON p.financial_year_id=f.id" + " WHERE f.company_id=? ORDER BY p.end_date ASC LIMIT 1;", id);//from ww w . j av a 2 s .c o m try { final ResultSet rs = stmt.executeQuery(); try { final Calendar dt = new GregorianCalendar(); // i.e. today if (rs.next()) { financial_year = rs.getString(1); dt.setTime(rs.getDate(2)); dt.set(GregorianCalendar.DAY_OF_MONTH, 1); } else { financial_year = new Integer(dt.get(GregorianCalendar.YEAR)).toString(); } start_date = new Date(dt.getTime().getTime()); } finally { rs.close(); } } finally { stmt.close(); } }
From source file:com.emc.ecs.sync.service.DbService.java
protected boolean hasDateColumn(ResultSet rs, String name) throws SQLException { if (hasColumn(rs, name)) { rs.getDate(name); return !rs.wasNull(); }/*from www . jav a 2 s.c o m*/ return false; }
From source file:com.carfinance.module.vehiclemanage.domain.VehiclePeccancyRowMapper.java
public VehiclePeccancy mapRow(ResultSet rs, int arg1) throws SQLException { VehiclePeccancy vehiclePeccancy = new VehiclePeccancy(); vehiclePeccancy.setId(rs.getLong("id")); vehiclePeccancy.setCarframe_no(rs.getString("carframe_no")); vehiclePeccancy.setEngine_no(rs.getString("engine_no")); vehiclePeccancy.setLicense_plate(rs.getString("license_plate")); vehiclePeccancy.setPeccancy_at(rs.getDate("peccancy_at")); vehiclePeccancy.setPeccancy_place(rs.getString("peccancy_place")); vehiclePeccancy.setPeccancy_reason(rs.getString("peccancy_reason")); vehiclePeccancy.setPeccancy_price(rs.getDouble("peccancy_price")); vehiclePeccancy.setScore(rs.getInt("score")); vehiclePeccancy.setStatus(rs.getInt("status")); vehiclePeccancy.setArbitration(rs.getString("arbitration")); vehiclePeccancy.setEmployee_id(rs.getString("employee_id")); vehiclePeccancy.setEmployee_name(rs.getString("employee_name")); vehiclePeccancy.setCustomer_id(rs.getString("customer_id")); vehiclePeccancy.setCustomer_name(rs.getString("customer_name")); vehiclePeccancy.setCreate_at(rs.getDate("create_at")); vehiclePeccancy.setCreate_by(rs.getLong("create_by")); vehiclePeccancy.setCreate_at(rs.getDate("update_at")); vehiclePeccancy.setCreate_by(rs.getLong("update_by")); return vehiclePeccancy; }